@@ -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" data-x-href="https://dom.spec.whatwg.org/#dom-mutationobserverinit-childlist"><code>childList</code></dfn></li>
3345
3367
<li><dfn data-x="mo characterData" data-x-href="https://dom.spec.whatwg.org/#dom-mutationobserverinit-characterdata"><code>characterData</code></dfn></li>
3346
3368
<li><dfn data-x="mo subtree" data-x-href="https://dom.spec.whatwg.org/#dom-mutationobserverinit-subtree"><code>subtree</code></dfn></li>
3369
+ <li><dfn data-x="mo attributes" data-xhref="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>
@@ -53400,6 +53423,9 @@ interface <dfn interface>HTMLSelectElement</dfn> : <span>HTMLElement</span> {
53400
53423
<li><p>Return <var>options</var>.</p></li>
53401
53424
</ol>
53402
53425
53426
+ <p>Every <code>select</code> element has <dfn>select descendant selectedoption elements</dfn>,
53427
+ which is a <span>list</span> of <code>selectedoption</code> elements, initially « ».</p>
53428
+
53403
53429
<p>The <dfn element-attr for="select"><code data-x="attr-select-required">required</code></dfn>
53404
53430
attribute is a <span>boolean attribute</span>. When specified, the user will be required to select
53405
53431
a value before submitting the form.</p>
@@ -53446,10 +53472,23 @@ interface <dfn interface>HTMLSelectElement</dfn> : <span>HTMLElement</span> {
53446
53472
through a click, or through unfocusing the element after changing its value, or through a <span
53447
53473
data-x="option-command">menu command</span>, or through any other mechanism), and before the
53448
53474
relevant user interaction event <!-- interaction event spec point --> is queued (e.g. before the
53449
- <code data-x="event-click">click</code> event), the user agent must set the <span
53450
- data-x="concept-option-selectedness">selectedness</span> of the picked <code>option</code> element
53451
- to true, set its <span data-x="concept-option-dirtiness">dirtiness</span> to true, and then
53452
- <span>send <code>select</code> update notifications</span>.</p>
53475
+ <code data-x="event-click">click</code> event), the user agent must run the following steps given
53476
+ the <code>select</code> <var>select</var> and the picked <code>option</code>
53477
+ <var>option</var>:</p>
53478
+
53479
+ <ol>
53480
+ <li><p>Set the <span data-x="concept-option-selectedness">selectedness</span> of
53481
+ <var>option</var> to true.</p></li>
53482
+
53483
+ <li><p>Set the <span data-x="concept-option-dirtiness">dirtiness</span> of <var>option</var> to
53484
+ true.</p></li>
53485
+
53486
+ <li><p><span>Send <code>select</code> update notifications</span>.</p></li>
53487
+
53488
+ <li><p>For each <var>selectedoption</var> in <var>select</var>'s <span>select descendant
53489
+ selectedoption elements</span>, run <span>clone an option into a selectedoption</span> given
53490
+ <var>option</var> and <var>selectedoption</var>.</p></li>
53491
+ </ol>
53453
53492
53454
53493
<p>If the <code data-x="attr-select-multiple">multiple</code> attribute is absent, whenever an
53455
53494
<code>option</code> element in the <code>select</code> element's <span
@@ -53478,23 +53517,33 @@ interface <dfn interface>HTMLSelectElement</dfn> : <span>HTMLElement</span> {
53478
53517
53479
53518
<ol>
53480
53519
<li><p>If <var>element</var>'s <code data-x="attr-select-multiple">multiple</code> attribute is
53481
- absent, and <var>element</var>'s <span data-x="concept-select-size">display size</span> is 1,
53482
- and no <code>option</code> elements in the <var>element</var>'s <span
53520
+ absent, then return.</p></li>
53521
+
53522
+ <li><p>If <var>element</var>'s <span data-x="concept-select-size">display size</span> is 1, and
53523
+ no <code>option</code> elements in the <var>element</var>'s <span
53483
53524
data-x="concept-select-option-list">list of options</span> have their <span
53484
53525
data-x="concept-option-selectedness">selectedness</span> set to true, then set the <span
53485
- data-x="concept-option-selectedness">selectedness</span> of the first <code>option</code>
53486
- element in the <span data-x="concept-select-option-list">list of options</span> in
53487
- <span>tree order</span> that is not <span data-x="concept-option-disabled">disabled</span>,
53488
- if any, to true, and return.</p></li>
53526
+ data-x="concept-option-selectedness">selectedness</span> of the first <code>option</code> element
53527
+ in the <span data-x="concept-select-option-list">list of options</span> in <span>tree
53528
+ order</span> that is not <span data-x="concept-option-disabled">disabled</span>, if any, to true ,
53529
+ and return.</p></li>
53489
53530
53490
- <li><p>If <var>element</var>'s <code data-x="attr-select-multiple">multiple</code> attribute is
53491
- absent, and two or more <code>option</code> elements in <var>element</var>'s <span
53531
+ <li><p>If two or more <code>option</code> elements in <var>element</var>'s <span
53492
53532
data-x="concept-select-option-list">list of options</span> have their <span
53493
53533
data-x="concept-option-selectedness">selectedness</span> set to true, then set the <span
53494
53534
data-x="concept-option-selectedness">selectedness</span> of all but the last <code>option</code>
53495
53535
element with its <span data-x="concept-option-selectedness">selectedness</span> set to true in
53496
53536
the <span data-x="concept-select-option-list">list of options</span> in <span>tree order</span>
53497
53537
to false.</p></li>
53538
+
53539
+ <li><p>Let <var>option</var> be the first <code>option</code> in <var>element</var>'s <span
53540
+ data-x="concept-select-option-list">list of options</span> which has its <span
53541
+ data-x="concept-option-selectedness">selectedness</span> set to true, or null if there is no such
53542
+ <code>option</code>.</p></li>
53543
+
53544
+ <li><p>For each <var>selectedoption</var> in <var>element</var>'s <span>select descendant
53545
+ selectedoption elements</span>, run <span>clone an option into a selectedoption</span> given
53546
+ <var>option</var> and <var>selectedoption</var>.</p></li>
53498
53547
</ol>
53499
53548
53500
53549
<p>The <dfn>option insertion steps</dfn>, given <var>option</var> and <var>insertionPoint</var>,
@@ -53810,14 +53859,27 @@ interface <dfn interface>HTMLSelectElement</dfn> : <span>HTMLElement</span> {
53810
53859
data-x="concept-option-selectedness">selectedness</span> set to true, if any. If there isn't one,
53811
53860
then it must return the empty string.</p>
53812
53861
53813
- <p>On setting, the <code data-x="dom-select-value">value</code> attribute must set the <span
53814
- data-x="concept-option-selectedness">selectedness</span> of all the <code>option</code> elements
53815
- in the <span data-x="concept-select-option-list">list of options</span> to false, and then the
53816
- first <code>option</code> element in the <span data-x="concept-select-option-list">list of
53817
- options</span>, in <span>tree order</span>, whose <span data-x="concept-option-value">value</span>
53818
- is equal to the given new value, if any, must have its <span
53819
- data-x="concept-option-selectedness">selectedness</span> set to true and its <span
53820
- data-x="concept-option-dirtiness">dirtiness</span> set to true.</p>
53862
+ <p>On setting, the <code data-x="dom-select-value">value</code> attribute must run the following
53863
+ steps:</p>
53864
+
53865
+ <ol>
53866
+ <li><p>Set the <span data-x="concept-option-selectedness">selectedness</span> of all the
53867
+ <code>option</code> elements in the <span data-x="concept-select-option-list">list of
53868
+ options</span> to false</p></li>
53869
+
53870
+ <li><p>Let <var>option</var> be the first <code>option</code> element in the <span
53871
+ data-x="concept-select-option-list">list of options</span> in <span>tree order</span> whose <span
53872
+ data-x="concept-option-value">value</span> is equal to the new given value, otherwise
53873
+ null.</p></li>
53874
+
53875
+ <li><p>If <var>option</var> is not null, then set <var>option</var>'s <span
53876
+ data-x="concept-option-selectedness">selectedness</span> to true and its <span
53877
+ data-x="concept-option-dirtiness">dirtiness</span> to true.
53878
+
53879
+ <li><p>For each <var>selectedoption</var> in <var>select</var>'s <span>select descendant
53880
+ selectedoption elements</span>, run <span>clone an option into a selectedoption</span> given
53881
+ <var>option</var> and <var>selectedoption</var>.</p></li>
53882
+ </ol>
53821
53883
53822
53884
<p class="note">This can result in no element having a <span
53823
53885
data-x="concept-option-selectedness">selectedness</span> set to true even in the case of the
@@ -54336,6 +54398,16 @@ interface <dfn interface>HTMLOptionElement</dfn> : <span>HTMLElement</span> {
54336
54398
<span>drop-down box</span>, then set <var>select</var>'s <span>select fallback
54337
54399
button text</span> to the value of <var>option</var>'s <span
54338
54400
data-x="dom-option-label">label</span>.</p></li>
54401
+
54402
+ <li>
54403
+ <p>For each <var>selectedoption</var> of <var>select</var>'s <span>select descendant
54404
+ selectedoption elements</span>:</p>
54405
+
54406
+ <ol>
54407
+ <li><p>Run <span>clone an option into a selectedoption</span> given <var>option</var> and
54408
+ <var>selectedoption</var>.</p></li>
54409
+ </ol>
54410
+ </li>
54339
54411
</ol>
54340
54412
54341
54413
<p>The <code>option</code> <span>HTML element insertion steps</span>, given
@@ -54345,8 +54417,9 @@ interface <dfn interface>HTMLOptionElement</dfn> : <span>HTMLElement</span> {
54345
54417
<li><p>Run the <span>mutation observer observe algorithm</span> given <var>insertedOption</var>'s
54346
54418
<span>option element mutation observer</span>, <var>insertedOption</var>, and a
54347
54419
<code>MutationObserverInit</code> with <code data-x="mo characterData">characterData</code> set
54348
- to true, <code data-x="mo childList">childList</code> set to true, and <code data-x="mo
54349
- subtree">subtree</code> set to true.</p></li>
54420
+ to true, <code data-x="mo childList">childList</code> set to true, <code data-x="mo
54421
+ subtree">subtree</code> set to true, and <code data-x="mo attributes">attributes</code> set to
54422
+ true.</p></li>
54350
54423
</ol>
54351
54424
54352
54425
<p>The <code>option</code> <span>HTML element removing steps</span>, given
@@ -56046,6 +56119,115 @@ interface <dfn interface>HTMLLegendElement</dfn> : <span>HTMLElement</span> {
56046
56119
56047
56120
</div>
56048
56121
56122
+ <h4>The <dfn element><code>selectedoption</code></dfn> element</h4>
56123
+
56124
+ <p>The <code>selectedoption</code> element reflects the contents of a <code>select</code>
56125
+ element's currently selected <code>option</code> element. <code>selectedoption</code> elements can
56126
+ be used to declaratively show the selected <code>option</code> element's contents in a different
56127
+ part of the document, such as the <code>select</code> element's invoker button, with alternate
56128
+ rendering based on different selectors in the author's stylesheet.</p>
56129
+
56130
+ <p>Every time the selected <code>option</code> of a <code>select</code> switches from one option
56131
+ to another, or the currently selected <code>option</code>'s descendant DOM structure mutates, the
56132
+ <code>selectedoption</code> element removes all of its children and replaces them with a new
56133
+ cloned copy of the DOM structure of the <code>select</code>'s selected <code>option</code>
56134
+ element.</p>
56135
+
56136
+ <p><code>selectedoption</code> elements become associated with <code>select</code> elements when
56137
+ the <code>selectedoption</code> is a <span>descendant</span> of the <code>select</code>.</p>
56138
+
56139
+ <!-- TODO add code example(s) -->
56140
+
56141
+ <p>To <dfn>clone an option into a selectedoption</dfn>, given an <code>option</code> element
56142
+ <var>option</var> and a <code>selectedoption</code> element <var>selectedOption</var>:</p>
56143
+
56144
+ <ol>
56145
+ <li><p>Let <var>nodes</var> be « ».</p></li>
56146
+
56147
+ <li>
56148
+ <p>If <var>option</var> is not null, then for each <var>child</var> of <var>option</var>'s <span
56149
+ data-x="concept-tree-child">children</span>:</p>
56150
+
56151
+ <ol>
56152
+ <li><p>Let <var>childClone</var> be the result of running <span
56153
+ data-x="concept-node-clone">clone</span> given <var>child</var>, null, true.</p></li>
56154
+
56155
+ <li><p><span data-x="list append">Append</span> <var>childClone</var> to
56156
+ <var>nodes</var>.</p></li>
56157
+ </ol>
56158
+ </li>
56159
+
56160
+ <li><p>Run <span data-x="dom-parentnode-replacechildren">replaceChildren</span> on
56161
+ <var>selectedOption</var> given <var>nodes</var>.</p></li>
56162
+ </ol>
56163
+
56164
+ <p>The <dfn>selectedoption insertion steps</dfn>, given <var>selectedoption</var> and
56165
+ <var>insertionPoint</var>, are:</p>
56166
+
56167
+ <ol>
56168
+ <li><p>Let <var>firstAncestorSelect</var> be null.</p></li>
56169
+
56170
+ <li><p>Let <var>ancestor</var> be <var>selectedoption</var>'s <span>parent</span>.</p></li>
56171
+
56172
+ <li>
56173
+ <p><span>While</span> <var>firstAncestorSelect</var> is null and <var>ancestor</var> is not
56174
+ null:</p>
56175
+
56176
+ <ol>
56177
+ <li><p>If <var>ancestor</var> is a <code>select</code> element, then set
56178
+ <var>firstAncestorSelect</var> to <var>ancestor</var>.</p></li>
56179
+
56180
+ <li><p>Set <var>ancestor</var> to <var>ancestor</var>'s <span>parent</span>.</p></li>
56181
+ </ol>
56182
+ </li>
56183
+
56184
+ <li><p>If <var>firstAncestorSelect</var> is null, then return.</p></li>
56185
+
56186
+ <li><p><span data-x="list append">Append</span> <var>selectedoption</var> to
56187
+ <var>firstAncestorSelect</var>'s <span>select descendant selectedoption elements</span>.</p></li>
56188
+
56189
+ <li><p>Run <span>clone an option into a selectedoption</span> given the first <code>option</code>
56190
+ in <var>firstAncestorSelect</var>'s <span data-x="concept-select-option-list">list of
56191
+ options</span> whose <span data-x="concept-option-selectedness">selectedness</span> is true and
56192
+ <var>insertedNode</var>.</p></li>
56193
+ </ol>
56194
+
56195
+ <p>The <dfn>selectedoption removal steps</dfn>, given <var>selectedoption</var> and
56196
+ <var>oldParent</var>, are:</p>
56197
+
56198
+ <ol>
56199
+ <li>
56200
+ <p>For each <var>ancestor</var> of <var>selectedoption</var>'s <span
56201
+ data-x="ancestor">ancestors</span>:</p>
56202
+
56203
+ <ol>
56204
+ <li><p>If <var>ancestor</var> is a <code>select</code> element, then return.</p></li>
56205
+ </ol>
56206
+ </li>
56207
+
56208
+ <li>
56209
+ <p>For each <var>ancestor</var> of <var>oldParent</var>'s <span data-x="inclusive
56210
+ ancestor">inclusive ancestors</span>:</p>
56211
+
56212
+ <ol>
56213
+ <li>
56214
+ <p>If <var>ancestor</var> is a <code>select</code> element, then:</p>
56215
+
56216
+ <ol>
56217
+ <li><p><span data-x="list remove">remove</span> <var>selectedoption</var> from
56218
+ <var>ancestor</var>'s <span>select descendant selectedoption elements</span>.</p></li>
56219
+
56220
+ <li><p>Run <span>clone an option into a selectedoption</span> given null and
56221
+ <var>selectedoption</var>.</p></li>
56222
+
56223
+ <li><p>Return.</p></li>
56224
+ </ol>
56225
+ </li>
56226
+ </ol>
56227
+ </li>
56228
+ </ol>
56229
+
56230
+ <!-- TODO: call the thing during selectedness setting algorithm and mutationobserver. -->
56049
56231
56050
56232
56051
56233
<h4 split-filename="form-control-infrastructure">Form control infrastructure</h4>
0 commit comments