Skip to content

Commit 04e9fcd

Browse files
committed
Add selectedoptionattribute for <select> elements
1 parent b146888 commit 04e9fcd

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
@@ -53340,6 +53340,8 @@ interface <dfn interface>HTMLSelectElement</dfn> : <span>HTMLElement</span> {
5334053340
undefined <span data-x="dom-select-showPicker">showPicker</span>();
5334153341

5334253342
readonly attribute <span>NodeList</span> <span data-x="dom-lfe-labels">labels</span>;
53343+
53344+
attribute <code data-x="selectedoption">HTMLSelectedOptionElement</code>? <span data-x="dom-selectedoptionelement">selectedOptionElement</span>;
5334353345
};</code></pre>
5334453346
</dd>
5334553347
<dd w-dev>Uses <code>HTMLSelectElement</code>.</dd>
@@ -53401,6 +53403,21 @@ interface <dfn interface>HTMLSelectElement</dfn> : <span>HTMLElement</span> {
5340153403
<p>Every <code>select</code> element has <dfn>select descendant selectedoption elements</dfn>,
5340253404
which is a <span>list</span> of <code>selectedoption</code> elements, initially « ».</p>
5340353405

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

5346153478
<li><p><span>Send <code>select</code> update notifications</span>.</p></li>
5346253479

53463-
<li><p>For each <var>selectedoption</var> in <var>select</var>'s <span>select descendant
53480+
<li><p>For each <var>selectedoption</var> in <var>select</var>'s <span>select target
5346453481
selectedoption elements</span>, run <span>clone an option into a selectedoption</span> given
5346553482
<var>option</var> and <var>selectedoption</var>.</p></li>
5346653483
</ol>
@@ -53516,7 +53533,7 @@ interface <dfn interface>HTMLSelectElement</dfn> : <span>HTMLElement</span> {
5351653533
data-x="concept-option-selectedness">selectedness</span> set to true, or null if there is no such
5351753534
<code>option</code>.</p></li>
5351853535

53519-
<li><p>For each <var>selectedoption</var> in <var>element</var>'s <span>select descendant
53536+
<li><p>For each <var>selectedoption</var> in <var>element</var>'s <span>select target
5352053537
selectedoption elements</span>, run <span>clone an option into a selectedoption</span> given
5352153538
<var>option</var> and <var>selectedoption</var>.</p></li>
5352253539
</ol>
@@ -53801,7 +53818,7 @@ interface <dfn interface>HTMLSelectElement</dfn> : <span>HTMLElement</span> {
5380153818
data-x="concept-option-selectedness">selectedness</span> to true and its <span
5380253819
data-x="concept-option-dirtiness">dirtiness</span> to true.
5380353820

53804-
<li><p>For each <var>selectedoption</var> in <var>select</var>'s <span>select descendant
53821+
<li><p>For each <var>selectedoption</var> in <var>select</var>'s <span>select target
5380553822
selectedoption elements</span>, run <span>clone an option into a selectedoption</span> given
5380653823
<var>option</var> and <var>selectedoption</var>.</p></li>
5380753824
</ol>
@@ -53924,6 +53941,64 @@ interface <dfn interface>HTMLSelectElement</dfn> : <span>HTMLElement</span> {
5392453941
&hellip;</code></pre>
5392553942
</div>
5392653943

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

5392854003

5392954004
<h4>The <dfn element><code>datalist</code></dfn> element</h4>
@@ -54295,7 +54370,7 @@ interface <dfn interface>HTMLOptionElement</dfn> : <span>HTMLElement</span> {
5429554370
data-x="dom-option-label">label</span>.</p></li>
5429654371

5429754372
<li>
54298-
<p>For each <var>selectedoption</var> of <var>select</var>'s <span>select descendant
54373+
<p>For each <var>selectedoption</var> of <var>select</var>'s <span>select target
5429954374
selectedoption elements</span>:</p>
5430054375

5430154376
<ol>

0 commit comments

Comments
 (0)