Skip to content

Commit 12edc88

Browse files
committed
Add selectedoptionattribute for <select> elements
1 parent 4419417 commit 12edc88

File tree

1 file changed

+79
-4
lines changed

1 file changed

+79
-4
lines changed

source

+79-4
Original file line numberDiff line numberDiff line change
@@ -53335,6 +53335,8 @@ interface <dfn interface>HTMLSelectElement</dfn> : <span>HTMLElement</span> {
5333553335
undefined <span data-x="dom-select-showPicker">showPicker</span>();
5333653336

5333753337
readonly attribute <span>NodeList</span> <span data-x="dom-lfe-labels">labels</span>;
53338+
53339+
attribute <code data-x="selectedoption">HTMLSelectedOptionElement</code>? <span data-x="dom-selectedoptionelement">selectedOptionElement</span>;
5333853340
};</code></pre>
5333953341
</dd>
5334053342
<dd w-dev>Uses <code>HTMLSelectElement</code>.</dd>
@@ -53396,6 +53398,21 @@ interface <dfn interface>HTMLSelectElement</dfn> : <span>HTMLElement</span> {
5339653398
<p>Every <code>select</code> element has <dfn>select descendant selectedoption elements</dfn>,
5339753399
which is a <span>list</span> of <code>selectedoption</code> elements, initially « ».</p>
5339853400

53401+
<p>To get the <dfn>select target selectedoption elements</dfn>, given a <code>select</code>
53402+
<var>select</var>:</p>
53403+
53404+
<ol>
53405+
<li><p>Let <var>selectedoptions</var> be <var>select</var>'s <span>select descendant
53406+
selectedoption elements</span>.</p></li>
53407+
53408+
<!-- TODO dom-selectedoptionelement can likely be overriden by script, but the "limited to only
53409+
known values" getter steps don't seem callable either. -->
53410+
<li><p><span data-x="list append">Append</span> the value of <var>select</var>'s <code
53411+
data-x="dom-selectedoptionelement">selectedOptionElement</code>, if it is non-null.</p></li>
53412+
53413+
<li><p>Return <var>selectedoptions</var>.</p></li>
53414+
</ol>
53415+
5339953416
<p>The <dfn element-attr for="select"><code data-x="attr-select-required">required</code></dfn>
5340053417
attribute is a <span>boolean attribute</span>. When specified, the user will be required to select
5340153418
a value before submitting the form.</p>
@@ -53455,7 +53472,7 @@ interface <dfn interface>HTMLSelectElement</dfn> : <span>HTMLElement</span> {
5345553472

5345653473
<li><p><span>Send <code>select</code> update notifications</span>.</p></li>
5345753474

53458-
<li><p>For each <var>selectedoption</var> in <var>select</var>'s <span>select descendant
53475+
<li><p>For each <var>selectedoption</var> in <var>select</var>'s <span>select target
5345953476
selectedoption elements</span>, run <span>clone an option into a selectedoption</span> given
5346053477
<var>option</var> and <var>selectedoption</var>.</p></li>
5346153478
</ol>
@@ -53511,7 +53528,7 @@ interface <dfn interface>HTMLSelectElement</dfn> : <span>HTMLElement</span> {
5351153528
data-x="concept-option-selectedness">selectedness</span> set to true, or null if there is no such
5351253529
<code>option</code>.</p></li>
5351353530

53514-
<li><p>For each <var>selectedoption</var> in <var>element</var>'s <span>select descendant
53531+
<li><p>For each <var>selectedoption</var> in <var>element</var>'s <span>select target
5351553532
selectedoption elements</span>, run <span>clone an option into a selectedoption</span> given
5351653533
<var>option</var> and <var>selectedoption</var>.</p></li>
5351753534
</ol>
@@ -53796,7 +53813,7 @@ interface <dfn interface>HTMLSelectElement</dfn> : <span>HTMLElement</span> {
5379653813
data-x="concept-option-selectedness">selectedness</span> to true and its <span
5379753814
data-x="concept-option-dirtiness">dirtiness</span> to true.
5379853815

53799-
<li><p>For each <var>selectedoption</var> in <var>select</var>'s <span>select descendant
53816+
<li><p>For each <var>selectedoption</var> in <var>select</var>'s <span>select target
5380053817
selectedoption elements</span>, run <span>clone an option into a selectedoption</span> given
5380153818
<var>option</var> and <var>selectedoption</var>.</p></li>
5380253819
</ol>
@@ -53919,6 +53936,64 @@ interface <dfn interface>HTMLSelectElement</dfn> : <span>HTMLElement</span> {
5391953936
&hellip;</code></pre>
5392053937
</div>
5392153938

53939+
<h4>The <code data-x="attr-selectedoptionelement">selectedoptionelement</code> attribute</h4>
53940+
53941+
<p><code>select</code> elements may have the <dfn element-attr
53942+
for="select"><code data-x="attr-selectedoptionelement">selectedoptionelement</code></dfn>
53943+
attribute. When specified its value must be the <span data-x="concept-ID">ID</span> of a
53944+
<code>selectedoption</code> element in the same <span>tree</span> as the <code>select</code> with
53945+
the <code data-x="attr-selectedoptionelement">selectedoptionelement</code> attribute. The target
53946+
<code>selectedoption</code> will update its contents to match the currently selected
53947+
<code>option</code> of the <code>select</code>.</p>
53948+
53949+
<div class="example">
53950+
<p>The following code shows how the <code
53951+
data-x="attr-selectedoptionelement">selectedoptionelement</code> attribute can be used to render
53952+
a <code>select</code> element's value outside of the <code>select</code>:</p>
53953+
53954+
<pre><code class="html">&lt;label for="pet-select">Choose a pet:&lt;/label>
53955+
&lt;select id="pet-select" selectedoptionelement="summary-value">
53956+
&lt;option>dog&lt;/option>
53957+
&lt;option>cat&lt;/option>
53958+
&lt;/select>
53959+
&lt;p>Summary: you chose the &lt;selectedoption id="summary-value">&lt;/selectedoption>.&lt;p></code></pre>
53960+
</div>
53961+
53962+
<p>The <dfn attribute for="select"><code
53963+
data-x="dom-selectedoptionelement">selectedOptionElement</code></dfn> IDL attribute must
53964+
<span>reflect</span> the <code data-x="attr-selectedoptionelement">selectedoptionelement</code>
53965+
attribute, <span>limited to only known values</span>.</p>
53966+
53967+
<p>The following <span data-x="concept-element-attributes-change-ext">attribute change
53968+
steps</span> given <var>element</var>, <var>localName</var>, <var>oldValue</var>,
53969+
<var>value</var>, and <var>namespace</var>, are used for <code>select</code> elements:</p>
53970+
53971+
<ol>
53972+
<li><p>If <var>namespace</var> is not null, then return.</p></li>
53973+
53974+
<li><p>If <var>localName</var> is not <code
53975+
data-x="attr-selectedoptionelement">selectedoptionelement</code>, then return.</p></li>
53976+
53977+
<li><p>Let <var>oldSelectedoption</var> be the first <code>selectedoption</code> element in
53978+
<span>tree order</span> in <var>element</var>'s <span>root</span> whose <span
53979+
data-x="concept-ID">ID</span> is <var>oldValue</var> if one exists, otherwise null.</p></li>
53980+
53981+
<li><p>Let <var>newSelectedoption</var> be the first <code>selectedoption</code> element in
53982+
<span>tree order</span> in <var>element</var>'s <span>root</span> whose <span
53983+
data-x="concept-ID">ID</span> is <var>value</var> if one exists, otherwise null.</p></li>
53984+
53985+
<li><p>If <var>oldSelectedoption</var> is eequal to <var>newSelectedoption</var>, then
53986+
return.</p></li>
53987+
53988+
<li><p>If <var>oldSelectedoption</var> is not null, then run <span>clone an option into a
53989+
selectedoption</span> given null and <var>oldSelectedOption</var>.</p></li>
53990+
53991+
<li><p>If <var>newSelectedoption</var> is not null, then run <span>clone an option into a
53992+
selectedoption</span> given the value of <var>element</var>'s <code
53993+
data-x="dom-selectedoptionelement">selectedOptionElement</code> and
53994+
<var>newSelectedOption</var>.</p></li>
53995+
</ol>
53996+
5392253997

5392353998

5392453999
<h4>The <dfn element><code>datalist</code></dfn> element</h4>
@@ -54319,7 +54394,7 @@ interface <dfn interface>HTMLOptionElement</dfn> : <span>HTMLElement</span> {
5431954394
<var>selectedOption</var>'s <span data-x="dom-option-label">label</span>.</p></li>
5432054395

5432154396
<li>
54322-
<p>For each <var>selectedoption</var> of <var>select</var>'s <span>select descendant
54397+
<p>For each <var>selectedoption</var> of <var>select</var>'s <span>select target
5432354398
selectedoption elements</span>:</p>
5432454399

5432554400
<ol>

0 commit comments

Comments
 (0)