Skip to content

Commit 939fe27

Browse files
committed
Add selectedoptionattribute for <select> elements
1 parent ff70b3a commit 939fe27

File tree

1 file changed

+79
-4
lines changed

1 file changed

+79
-4
lines changed

source

Lines changed: 79 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53365,6 +53365,8 @@ interface <dfn interface>HTMLSelectElement</dfn> : <span>HTMLElement</span> {
5336553365
undefined <span data-x="dom-select-showPicker">showPicker</span>();
5336653366

5336753367
readonly attribute <span>NodeList</span> <span data-x="dom-lfe-labels">labels</span>;
53368+
53369+
attribute <code data-x="selectedoption">HTMLSelectedOptionElement</code>? <span data-x="dom-selectedoptionelement">selectedOptionElement</span>;
5336853370
};</code></pre>
5336953371
</dd>
5337053372
<dd w-dev>Uses <code>HTMLSelectElement</code>.</dd>
@@ -53426,6 +53428,21 @@ interface <dfn interface>HTMLSelectElement</dfn> : <span>HTMLElement</span> {
5342653428
<p>Every <code>select</code> element has <dfn>select descendant selectedoption elements</dfn>,
5342753429
which is a <span>list</span> of <code>selectedoption</code> elements, initially « ».</p>
5342853430

53431+
<p>To get the <dfn>select target selectedoption elements</dfn>, given a <code>select</code>
53432+
<var>select</var>:</p>
53433+
53434+
<ol>
53435+
<li><p>Let <var>selectedoptions</var> be <var>select</var>'s <span>select descendant
53436+
selectedoption elements</span>.</p></li>
53437+
53438+
<!-- TODO dom-selectedoptionelement can likely be overriden by script, but the "limited to only
53439+
known values" getter steps don't seem callable either. -->
53440+
<li><p><span data-x="list append">Append</span> the value of <var>select</var>'s <code
53441+
data-x="dom-selectedoptionelement">selectedOptionElement</code>, if it is non-null.</p></li>
53442+
53443+
<li><p>Return <var>selectedoptions</var>.</p></li>
53444+
</ol>
53445+
5342953446
<p>The <dfn element-attr for="select"><code data-x="attr-select-required">required</code></dfn>
5343053447
attribute is a <span>boolean attribute</span>. When specified, the user will be required to select
5343153448
a value before submitting the form.</p>
@@ -53485,7 +53502,7 @@ interface <dfn interface>HTMLSelectElement</dfn> : <span>HTMLElement</span> {
5348553502

5348653503
<li><p><span>Send <code>select</code> update notifications</span>.</p></li>
5348753504

53488-
<li><p>For each <var>selectedoption</var> in <var>select</var>'s <span>select descendant
53505+
<li><p>For each <var>selectedoption</var> in <var>select</var>'s <span>select target
5348953506
selectedoption elements</span>, run <span>clone an option into a selectedoption</span> given
5349053507
<var>option</var> and <var>selectedoption</var>.</p></li>
5349153508
</ol>
@@ -53541,7 +53558,7 @@ interface <dfn interface>HTMLSelectElement</dfn> : <span>HTMLElement</span> {
5354153558
data-x="concept-option-selectedness">selectedness</span> set to true, or null if there is no such
5354253559
<code>option</code>.</p></li>
5354353560

53544-
<li><p>For each <var>selectedoption</var> in <var>element</var>'s <span>select descendant
53561+
<li><p>For each <var>selectedoption</var> in <var>element</var>'s <span>select target
5354553562
selectedoption elements</span>, run <span>clone an option into a selectedoption</span> given
5354653563
<var>option</var> and <var>selectedoption</var>.</p></li>
5354753564
</ol>
@@ -53876,7 +53893,7 @@ interface <dfn interface>HTMLSelectElement</dfn> : <span>HTMLElement</span> {
5387653893
data-x="concept-option-selectedness">selectedness</span> to true and its <span
5387753894
data-x="concept-option-dirtiness">dirtiness</span> to true.
5387853895

53879-
<li><p>For each <var>selectedoption</var> in <var>select</var>'s <span>select descendant
53896+
<li><p>For each <var>selectedoption</var> in <var>select</var>'s <span>select target
5388053897
selectedoption elements</span>, run <span>clone an option into a selectedoption</span> given
5388153898
<var>option</var> and <var>selectedoption</var>.</p></li>
5388253899
</ol>
@@ -53999,6 +54016,64 @@ interface <dfn interface>HTMLSelectElement</dfn> : <span>HTMLElement</span> {
5399954016
&hellip;</code></pre>
5400054017
</div>
5400154018

54019+
<h4>The <code data-x="attr-selectedoptionelement">selectedoptionelement</code> attribute</h4>
54020+
54021+
<p><code>select</code> elements may have the <dfn element-attr
54022+
for="select"><code data-x="attr-selectedoptionelement">selectedoptionelement</code></dfn>
54023+
attribute. When specified its value must be the <span data-x="concept-ID">ID</span> of a
54024+
<code>selectedoption</code> element in the same <span>tree</span> as the <code>select</code> with
54025+
the <code data-x="attr-selectedoptionelement">selectedoptionelement</code> attribute. The target
54026+
<code>selectedoption</code> will update its contents to match the currently selected
54027+
<code>option</code> of the <code>select</code>.</p>
54028+
54029+
<div class="example">
54030+
<p>The following code shows how the <code
54031+
data-x="attr-selectedoptionelement">selectedoptionelement</code> attribute can be used to render
54032+
a <code>select</code> element's value outside of the <code>select</code>:</p>
54033+
54034+
<pre><code class="html">&lt;label for="pet-select">Choose a pet:&lt;/label>
54035+
&lt;select id="pet-select" selectedoptionelement="summary-value">
54036+
&lt;option>dog&lt;/option>
54037+
&lt;option>cat&lt;/option>
54038+
&lt;/select>
54039+
&lt;p>Summary: you chose the &lt;selectedoption id="summary-value">&lt;/selectedoption>.&lt;p></code></pre>
54040+
</div>
54041+
54042+
<p>The <dfn attribute for="select"><code
54043+
data-x="dom-selectedoptionelement">selectedOptionElement</code></dfn> IDL attribute must
54044+
<span>reflect</span> the <code data-x="attr-selectedoptionelement">selectedoptionelement</code>
54045+
attribute, <span>limited to only known values</span>.</p>
54046+
54047+
<p>The following <span data-x="concept-element-attributes-change-ext">attribute change
54048+
steps</span> given <var>element</var>, <var>localName</var>, <var>oldValue</var>,
54049+
<var>value</var>, and <var>namespace</var>, are used for <code>select</code> elements:</p>
54050+
54051+
<ol>
54052+
<li><p>If <var>namespace</var> is not null, then return.</p></li>
54053+
54054+
<li><p>If <var>localName</var> is not <code
54055+
data-x="attr-selectedoptionelement">selectedoptionelement</code>, then return.</p></li>
54056+
54057+
<li><p>Let <var>oldSelectedoption</var> be the first <code>selectedoption</code> element in
54058+
<span>tree order</span> in <var>element</var>'s <span>root</span> whose <span
54059+
data-x="concept-ID">ID</span> is <var>oldValue</var> if one exists, otherwise null.</p></li>
54060+
54061+
<li><p>Let <var>newSelectedoption</var> be the first <code>selectedoption</code> element in
54062+
<span>tree order</span> in <var>element</var>'s <span>root</span> whose <span
54063+
data-x="concept-ID">ID</span> is <var>value</var> if one exists, otherwise null.</p></li>
54064+
54065+
<li><p>If <var>oldSelectedoption</var> is eequal to <var>newSelectedoption</var>, then
54066+
return.</p></li>
54067+
54068+
<li><p>If <var>oldSelectedoption</var> is not null, then run <span>clone an option into a
54069+
selectedoption</span> given null and <var>oldSelectedOption</var>.</p></li>
54070+
54071+
<li><p>If <var>newSelectedoption</var> is not null, then run <span>clone an option into a
54072+
selectedoption</span> given the value of <var>element</var>'s <code
54073+
data-x="dom-selectedoptionelement">selectedOptionElement</code> and
54074+
<var>newSelectedOption</var>.</p></li>
54075+
</ol>
54076+
5400254077

5400354078

5400454079
<h4>The <dfn element><code>datalist</code></dfn> element</h4>
@@ -54403,7 +54478,7 @@ interface <dfn interface>HTMLOptionElement</dfn> : <span>HTMLElement</span> {
5440354478
data-x="dom-option-label">label</span>.</p></li>
5440454479

5440554480
<li>
54406-
<p>For each <var>selectedoption</var> of <var>select</var>'s <span>select descendant
54481+
<p>For each <var>selectedoption</var> of <var>select</var>'s <span>select target
5440754482
selectedoption elements</span>:</p>
5440854483

5440954484
<ol>

0 commit comments

Comments
 (0)