@@ -1807,6 +1807,22 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
1807
1807
</li>
1808
1808
</ol>
1809
1809
1810
+ <p>The <span data-x="concept-node-post-connection-ext">post-connection steps</span> for the HTML
1811
+ Standard, given <var>insertedNode</var>, are defined as the following:</p>
1812
+
1813
+ <ol>
1814
+ <li>
1815
+ <p>For each <var>descendant</var> of <var>insertedNode</var>'s <span data-x="inclusive
1816
+ descendant">inclusive descendants</span> in <span>tree order</span>:</p>
1817
+
1818
+ <ol>
1819
+ <li><p>If <var>descendant</var> is a <code>selectedoption</code> element, then run the
1820
+ <span>selectedoption insertion steps</span> given <var>descendant</var> and
1821
+ <var>insertedNode</var>'s <span>parent</span>.</p></li>
1822
+ </ol>
1823
+ </li>
1824
+ </ol>
1825
+
1810
1826
<p>The <span data-x="concept-node-remove-ext">removing steps</span> for the HTML Standard, given
1811
1827
<var>removedNode</var> and <var>oldParent</var>, are defined as the following:</p>
1812
1828
@@ -1857,6 +1873,10 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
1857
1873
<ol>
1858
1874
<li><p>If <var>descendant</var> is an <code>option</code> element, then run the <span>option
1859
1875
removal steps</span> given <var>descendant</var> and <var>oldParent</var>.</p></li>
1876
+
1877
+ <li><p>If <var>descendant</var> is a <code>selectedoption</code> element, then run the
1878
+ <span>selectedoption removal steps</span> given <var>descendant</var> and
1879
+ <var>oldParent</var>.</p></li>
1860
1880
</ol>
1861
1881
</li>
1862
1882
</ol>
@@ -3222,6 +3242,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
3222
3242
<li><dfn data-x="dom-Element-id" data-x-href="https://dom.spec.whatwg.org/#dom-element-id"><code>id</code></dfn> attribute</li>
3223
3243
<li><dfn data-x="dom-Element-setAttribute" data-x-href="https://dom.spec.whatwg.org/#dom-element-setattribute"><code>setAttribute()</code></dfn> method</li>
3224
3244
<li><dfn data-x-href="https://dom.spec.whatwg.org/#dom-node-textcontent"><code>textContent</code></dfn> attribute</li>
3245
+ <li><dfn data-x="dom-parentnode-replacechildren" data-x-href="https://dom.spec.whatwg.org/#dom-parentnode-replacechildren"><code>replaceChildren()</code></dfn> method</li>
3225
3246
3226
3247
<li>The <dfn data-x-href="https://dom.spec.whatwg.org/#concept-tree">tree</dfn>, <dfn data-x-href="https://dom.spec.whatwg.org/#concept-shadow-tree">shadow tree</dfn>, and <dfn data-x-href="https://dom.spec.whatwg.org/#concept-node-tree">node tree</dfn> concepts</li>
3227
3248
<li>The <dfn data-x-href="https://dom.spec.whatwg.org/#concept-tree-order">tree order</dfn> and <dfn data-x-href="https://dom.spec.whatwg.org/#concept-shadow-including-tree-order">shadow-including tree order</dfn> concepts</li>
@@ -3257,6 +3278,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
3257
3278
<li>The <dfn data-x="concept-tree-descendant" data-x-href="https://dom.spec.whatwg.org/#concept-tree-descendant">descendant</dfn> concept</li>
3258
3279
<li>The <dfn data-x="concept-node-insert-ext" data-x-href="https://dom.spec.whatwg.org/#concept-node-insert-ext">insertion steps</dfn>,
3259
3280
<dfn data-x="concept-node-remove-ext" data-x-href="https://dom.spec.whatwg.org/#concept-node-remove-ext">removing steps</dfn>,
3281
+ <dfn data-x="concept-node-post-connection-ext" data-x-href="https://dom.spec.whatwg.org/#concept-node-post-connection-ext">post-connection steps</dfn>,
3260
3282
<dfn data-x="concept-node-adopt-ext" data-x-href="https://dom.spec.whatwg.org/#concept-node-adopt-ext">adopting steps</dfn>, and
3261
3283
<dfn data-x-href="https://dom.spec.whatwg.org/#concept-node-children-changed-ext">children changed steps</dfn> hooks for elements</li>
3262
3284
<li>The <dfn data-x="concept-element-attributes-change" data-x-href="https://dom.spec.whatwg.org/#concept-element-attributes-change">change</dfn>, <dfn data-x="concept-element-attributes-append" data-x-href="https://dom.spec.whatwg.org/#concept-element-attributes-append">append</dfn>, <dfn data-x="concept-element-attributes-remove" data-x-href="https://dom.spec.whatwg.org/#concept-element-attributes-remove">remove</dfn>, <dfn data-x="concept-element-attributes-replace" data-x-href="https://dom.spec.whatwg.org/#concept-element-attributes-replace">replace</dfn>, <dfn data-x="concept-element-attributes-get-by-namespace" data-x-href="https://dom.spec.whatwg.org/#concept-element-attributes-get-by-namespace">get an attribute by namespace and local name</dfn>, <dfn data-x="concept-element-attributes-set-value" data-x-href="https://dom.spec.whatwg.org/#concept-element-attributes-set-value">set value</dfn>, and <dfn data-x="concept-element-attributes-remove-by-namespace" data-x-href="https://dom.spec.whatwg.org/#concept-element-attributes-remove-by-namespace">remove an attribute by namespace and local name</dfn> algorithms for attributes</li>
@@ -3344,6 +3366,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
3344
3366
<li><dfn data-x="mo childList" href="https://dom.spec.whatwg.org/#dom-mutationobserverinit-childlist"><code>childList</code></dfn></li>
3345
3367
<li><dfn data-x="mo characterData" href="https://dom.spec.whatwg.org/#dom-mutationobserverinit-characterdata"><code>characterData</code></dfn></li>
3346
3368
<li><dfn data-x="mo subtree" href="https://dom.spec.whatwg.org/#dom-mutationobserverinit-subtree"><code>subtree</code></dfn></li>
3369
+ <li><dfn data-x="mo attributes" href="https://dom.spec.whatwg.org/#dom-mutationobserverinit-attributes"><code>attributes</code></dfn></li>
3347
3370
<li><dfn data-x-href="https://dom.spec.whatwg.org/#abortcontroller"><code>AbortController</code></dfn> and its
3348
3371
<dfn data-x="concept-AbortController-signal" data-x-href="https://dom.spec.whatwg.org/#abortcontroller-signal">signal</dfn></li>
3349
3372
<li><dfn data-x-href="https://dom.spec.whatwg.org/#abortsignal"><code>AbortSignal</code></dfn></li>
@@ -53422,6 +53445,9 @@ interface <dfn interface>HTMLSelectElement</dfn> : <span>HTMLElement</span> {
53422
53445
<li><p>Return <var>options</var>.</p></li>
53423
53446
</ol>
53424
53447
53448
+ <p>Every <code>select</code> element has <dfn>select descendant selectedoption elements</dfn>,
53449
+ which is a <span>list</span> of <code>selectedoption</code> elements, initially « ».</p>
53450
+
53425
53451
<p>The <dfn element-attr for="select"><code data-x="attr-select-required">required</code></dfn>
53426
53452
attribute is a <span>boolean attribute</span>. When specified, the user will be required to select
53427
53453
a value before submitting the form.</p>
@@ -53468,10 +53494,23 @@ interface <dfn interface>HTMLSelectElement</dfn> : <span>HTMLElement</span> {
53468
53494
through a click, or through unfocusing the element after changing its value, or through a <span
53469
53495
data-x="option-command">menu command</span>, or through any other mechanism), and before the
53470
53496
relevant user interaction event <!-- interaction event spec point --> is queued (e.g. before the
53471
- <code data-x="event-click">click</code> event), the user agent must set the <span
53472
- data-x="concept-option-selectedness">selectedness</span> of the picked <code>option</code> element
53473
- to true, set its <span data-x="concept-option-dirtiness">dirtiness</span> to true, and then
53474
- <span>send <code>select</code> update notifications</span>.</p>
53497
+ <code data-x="event-click">click</code> event), the user agent must run the following steps given
53498
+ the <code>select</code> <var>select</var> and the picked <code>option</code>
53499
+ <var>option</var>:</p>
53500
+
53501
+ <ol>
53502
+ <li><p>Set the <span data-x="concept-option-selectedness">selectedness</span> of
53503
+ <var>option</var> to true.</p></li>
53504
+
53505
+ <li><p>Set the <span data-x="concept-option-dirtiness">dirtiness</span> of <var>option</var> to
53506
+ true.</p></li>
53507
+
53508
+ <li><p><span>Send <code>select</code> update notifications</span>.</p></li>
53509
+
53510
+ <li><p>For each <var>selectedoption</var> in <var>select</var>'s <span>select descendant
53511
+ selectedoption elements</span>, run <span>clone an option into a selectedoption</span> given
53512
+ <var>option</var> and <var>selectedoption</var>.</p></li>
53513
+ </ol>
53475
53514
53476
53515
<p>If the <code data-x="attr-select-multiple">multiple</code> attribute is absent, whenever an
53477
53516
<code>option</code> element in the <code>select</code> element's <span
@@ -53500,23 +53539,33 @@ interface <dfn interface>HTMLSelectElement</dfn> : <span>HTMLElement</span> {
53500
53539
53501
53540
<ol>
53502
53541
<li><p>If <var>element</var>'s <code data-x="attr-select-multiple">multiple</code> attribute is
53503
- absent, and <var>element</var>'s <span data-x="concept-select-size">display size</span> is 1,
53504
- and no <code>option</code> elements in the <var>element</var>'s <span
53542
+ absent, then return.</p></li>
53543
+
53544
+ <li><p>If <var>element</var>'s <span data-x="concept-select-size">display size</span> is 1, and
53545
+ no <code>option</code> elements in the <var>element</var>'s <span
53505
53546
data-x="concept-select-option-list">list of options</span> have their <span
53506
53547
data-x="concept-option-selectedness">selectedness</span> set to true, then set the <span
53507
- data-x="concept-option-selectedness">selectedness</span> of the first <code>option</code>
53508
- element in the <span data-x="concept-select-option-list">list of options</span> in
53509
- <span>tree order</span> that is not <span data-x="concept-option-disabled">disabled</span>,
53510
- if any, to true, and return.</p></li>
53548
+ data-x="concept-option-selectedness">selectedness</span> of the first <code>option</code> element
53549
+ in the <span data-x="concept-select-option-list">list of options</span> in <span>tree
53550
+ order</span> that is not <span data-x="concept-option-disabled">disabled</span>, if any, to true ,
53551
+ and return.</p></li>
53511
53552
53512
- <li><p>If <var>element</var>'s <code data-x="attr-select-multiple">multiple</code> attribute is
53513
- absent, and two or more <code>option</code> elements in <var>element</var>'s <span
53553
+ <li><p>If two or more <code>option</code> elements in <var>element</var>'s <span
53514
53554
data-x="concept-select-option-list">list of options</span> have their <span
53515
53555
data-x="concept-option-selectedness">selectedness</span> set to true, then set the <span
53516
53556
data-x="concept-option-selectedness">selectedness</span> of all but the last <code>option</code>
53517
53557
element with its <span data-x="concept-option-selectedness">selectedness</span> set to true in
53518
53558
the <span data-x="concept-select-option-list">list of options</span> in <span>tree order</span>
53519
53559
to false.</p></li>
53560
+
53561
+ <li><p>Let <var>option</var> be the first <code>option</code> in <var>element</var>'s <span
53562
+ data-x="concept-select-option-list">list of options</span> which has its <span
53563
+ data-x="concept-option-selectedness">selectedness</span> set to true, or null if there is no such
53564
+ <code>option</code>.</p></li>
53565
+
53566
+ <li><p>For each <var>selectedoption</var> in <var>element</var>'s <span>select descendant
53567
+ selectedoption elements</span>, run <span>clone an option into a selectedoption</span> given
53568
+ <var>option</var> and <var>selectedoption</var>.</p></li>
53520
53569
</ol>
53521
53570
53522
53571
<p>The <dfn>option insertion steps</dfn>, given <var>option</var> and <var>insertionPoint</var>,
@@ -53835,14 +53884,27 @@ interface <dfn interface>HTMLSelectElement</dfn> : <span>HTMLElement</span> {
53835
53884
data-x="concept-option-selectedness">selectedness</span> set to true, if any. If there isn't one,
53836
53885
then it must return the empty string.</p>
53837
53886
53838
- <p>On setting, the <code data-x="dom-select-value">value</code> attribute must set the <span
53839
- data-x="concept-option-selectedness">selectedness</span> of all the <code>option</code> elements
53840
- in the <span data-x="concept-select-option-list">list of options</span> to false, and then the
53841
- first <code>option</code> element in the <span data-x="concept-select-option-list">list of
53842
- options</span>, in <span>tree order</span>, whose <span data-x="concept-option-value">value</span>
53843
- is equal to the given new value, if any, must have its <span
53844
- data-x="concept-option-selectedness">selectedness</span> set to true and its <span
53845
- data-x="concept-option-dirtiness">dirtiness</span> set to true.</p>
53887
+ <p>On setting, the <code data-x="dom-select-value">value</code> attribute must run the following
53888
+ steps:</p>
53889
+
53890
+ <ol>
53891
+ <li><p>Set the <span data-x="concept-option-selectedness">selectedness</span> of all the
53892
+ <code>option</code> elements in the <span data-x="concept-select-option-list">list of
53893
+ options</span> to false</p></li>
53894
+
53895
+ <li><p>Let <var>option</var> be the first <code>option</code> element in the <span
53896
+ data-x="concept-select-option-list">list of options</span> in <span>tree order</span> whose <span
53897
+ data-x="concept-option-value">value</span> is equal to the new given value, otherwise
53898
+ null.</p></li>
53899
+
53900
+ <li><p>If <var>option</var> is not null, then set <var>option</var>'s <span
53901
+ data-x="concept-option-selectedness">selectedness</span> to true and its <span
53902
+ data-x="concept-option-dirtiness">dirtiness</span> to true.
53903
+
53904
+ <li><p>For each <var>selectedoption</var> in <var>select</var>'s <span>select descendant
53905
+ selectedoption elements</span>, run <span>clone an option into a selectedoption</span> given
53906
+ <var>option</var> and <var>selectedoption</var>.</p></li>
53907
+ </ol>
53846
53908
53847
53909
<p class="note">This can result in no element having a <span
53848
53910
data-x="concept-option-selectedness">selectedness</span> set to true even in the case of the
@@ -54361,6 +54423,16 @@ interface <dfn interface>HTMLOptionElement</dfn> : <span>HTMLElement</span> {
54361
54423
<span>drop-down box</span>, then set <var>select</var>'s <span>select fallback
54362
54424
button text</span> to the value of <var>option</var>'s <span
54363
54425
data-x="dom-option-label">label</span>.</p></li>
54426
+
54427
+ <li>
54428
+ <p>For each <var>selectedoption</var> of <var>select</var>'s <span>select descendant
54429
+ selectedoption elements</span>:</p>
54430
+
54431
+ <ol>
54432
+ <li><p>Run <span>clone an option into a selectedoption</span> given <var>option</var> and
54433
+ <var>selectedoption</var>.</p></li>
54434
+ </ol>
54435
+ </li>
54364
54436
</ol>
54365
54437
54366
54438
<p>The <code>option</code> <span>HTML element insertion steps</span>, given
@@ -54370,8 +54442,9 @@ interface <dfn interface>HTMLOptionElement</dfn> : <span>HTMLElement</span> {
54370
54442
<li><p>Run the <span>mutation observer observe algorithm</span> given <var>insertedOption</var>'s
54371
54443
<span>option element mutation observer</span>, <var>insertedOption</var>, and a
54372
54444
<code>MutationObserverInit</code> with <code data-x="mo characterData">characterData</code> set
54373
- to true, <code data-x="mo childList">childList</code> set to true, and <code data-x="mo
54374
- subtree">subtree</code> set to true.</p></li>
54445
+ to true, <code data-x="mo childList">childList</code> set to true, <code data-x="mo
54446
+ subtree">subtree</code> set to true, and <code data-x="mo attributes">attributes</code> set to
54447
+ true.</p></li>
54375
54448
</ol>
54376
54449
54377
54450
<p>The <code>option</code> <span>HTML element removing steps</span>, given
@@ -56071,6 +56144,115 @@ interface <dfn interface>HTMLLegendElement</dfn> : <span>HTMLElement</span> {
56071
56144
56072
56145
</div>
56073
56146
56147
+ <h4>The <dfn element><code>selectedoption</code></dfn> element</h4>
56148
+
56149
+ <p>The <code>selectedoption</code> element reflects the contents of a <code>select</code>
56150
+ element's currently selected <code>option</code> element. <code>selectedoption</code> elements can
56151
+ be used to declaratively show the selected <code>option</code> element's contents in a different
56152
+ part of the document, such as the <code>select</code> element's invoker button, with alternate
56153
+ rendering based on different selectors in the author's stylesheet.</p>
56154
+
56155
+ <p>Every time the selected <code>option</code> of a <code>select</code> switches from one option
56156
+ to another, or the currently selected <code>option</code>'s descendant DOM structure mutates, the
56157
+ <code>selectedoption</code> element removes all of its children and replaces them with a new
56158
+ cloned copy of the DOM structure of the <code>select</code>'s selected <code>option</code>
56159
+ element.</p>
56160
+
56161
+ <p><code>selectedoption</code> elements become associated with <code>select</code> elements when
56162
+ the <code>selectedoption</code> is a <span>descendant</span> of the <code>select</code>.</p>
56163
+
56164
+ <!-- TODO add code example(s) -->
56165
+
56166
+ <p>To <dfn>clone an option into a selectedoption</dfn>, given an <code>option</code> element
56167
+ <var>option</var> and a <code>selectedoption</code> element <var>selectedOption</var>:</p>
56168
+
56169
+ <ol>
56170
+ <li><p>Let <var>nodes</var> be « ».</p></li>
56171
+
56172
+ <li>
56173
+ <p>If <var>option</var> is not null, then for each <var>child</var> of <var>option</var>'s <span
56174
+ data-x="concept-tree-child">children</span>:</p>
56175
+
56176
+ <ol>
56177
+ <li><p>Let <var>childClone</var> be the result of running <span
56178
+ data-x="concept-node-clone">clone</span> given <var>child</var>, null, true.</p></li>
56179
+
56180
+ <li><p><span data-x="list append">Append</span> <var>childClone</var> to
56181
+ <var>nodes</var>.</p></li>
56182
+ </ol>
56183
+ </li>
56184
+
56185
+ <li><p>Run <span data-x="dom-parentnode-replacechildren">replaceChildren</span> on
56186
+ <var>selectedOption</var> given <var>nodes</var>.</p></li>
56187
+ </ol>
56188
+
56189
+ <p>The <dfn>selectedoption insertion steps</dfn>, given <var>selectedoption</var> and
56190
+ <var>insertionPoint</var>, are:</p>
56191
+
56192
+ <ol>
56193
+ <li><p>Let <var>firstAncestorSelect</var> be null.</p></li>
56194
+
56195
+ <li><p>Let <var>ancestor</var> be <var>selectedoption</var>'s <span>parent</span>.</p></li>
56196
+
56197
+ <li>
56198
+ <p><span>While</span> <var>firstAncestorSelect</var> is null and <var>ancestor</var> is not
56199
+ null:</p>
56200
+
56201
+ <ol>
56202
+ <li><p>If <var>ancestor</var> is a <code>select</code> element, then set
56203
+ <var>firstAncestorSelect</var> to <var>ancestor</var>.</p></li>
56204
+
56205
+ <li><p>Set <var>ancestor</var> to <var>ancestor</var>'s <span>parent</span>.</p></li>
56206
+ </ol>
56207
+ </li>
56208
+
56209
+ <li><p>If <var>firstAncestorSelect</var> is null, then return.</p></li>
56210
+
56211
+ <li><p><span data-x="list append">Append</span> <var>selectedoption</var> to
56212
+ <var>firstAncestorSelect</var>'s <span>select descendant selectedoption elements</span>.</p></li>
56213
+
56214
+ <li><p>Run <span>clone an option into a selectedoption</span> given the first <code>option</code>
56215
+ in <var>firstAncestorSelect</var>'s <span data-x="concept-select-option-list">list of
56216
+ options</span> whose <span data-x="concept-option-selectedness">selectedness</span> is true and
56217
+ <var>insertedNode</var>.</p></li>
56218
+ </ol>
56219
+
56220
+ <p>The <dfn>selectedoption removal steps</dfn>, given <var>selectedoption</var> and
56221
+ <var>oldParent</var>, are:</p>
56222
+
56223
+ <ol>
56224
+ <li>
56225
+ <p>For each <var>ancestor</var> of <var>selectedoption</var>'s <span
56226
+ data-x="ancestor">ancestors</span>:</p>
56227
+
56228
+ <ol>
56229
+ <li><p>If <var>ancestor</var> is a <code>select</code> element, then return.</p></li>
56230
+ </ol>
56231
+ </li>
56232
+
56233
+ <li>
56234
+ <p>For each <var>ancestor</var> of <var>oldParent</var>'s <span data-x="inclusive
56235
+ ancestor">inclusive ancestors</span>:</p>
56236
+
56237
+ <ol>
56238
+ <li>
56239
+ <p>If <var>ancestor</var> is a <code>select</code> element, then:</p>
56240
+
56241
+ <ol>
56242
+ <li><p><span data-x="list remove">remove</span> <var>selectedoption</var> from
56243
+ <var>ancestor</var>'s <span>select descendant selectedoption elements</span>.</p></li>
56244
+
56245
+ <li><p>Run <span>clone an option into a selectedoption</span> given null and
56246
+ <var>selectedoption</var>.</p></li>
56247
+
56248
+ <li><p>Return.</p></li>
56249
+ </ol>
56250
+ </li>
56251
+ </ol>
56252
+ </li>
56253
+ </ol>
56254
+
56255
+ <!-- TODO: call the thing during selectedness setting algorithm and mutationobserver. -->
56074
56256
56075
56257
56076
56258
<h4 split-filename="form-control-infrastructure">Form control infrastructure</h4>
0 commit comments