Skip to content

Commit 50bf192

Browse files
committed
Add selectedoptionattribute for <select> elements
1 parent d9b6dc8 commit 50bf192

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

5334653346
readonly attribute <span>NodeList</span> <span data-x="dom-lfe-labels">labels</span>;
53347+
53348+
attribute <code data-x="selectedoption">HTMLSelectedOptionElement</code>? <span data-x="dom-selectedoptionelement">selectedOptionElement</span>;
5334753349
};</code></pre>
5334853350
</dd>
5334953351
<dd w-dev>Uses <code>HTMLSelectElement</code>.</dd>
@@ -53405,6 +53407,21 @@ interface <dfn interface>HTMLSelectElement</dfn> : <span>HTMLElement</span> {
5340553407
<p>Every <code>select</code> element has <dfn>select descendant selectedoption elements</dfn>,
5340653408
which is a <span>list</span> of <code>selectedoption</code> elements, initially « ».</p>
5340753409

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

5346553482
<li><p><span>Send <code>select</code> update notifications</span>.</p></li>
5346653483

53467-
<li><p>For each <var>selectedoption</var> in <var>select</var>'s <span>select descendant
53484+
<li><p>For each <var>selectedoption</var> in <var>select</var>'s <span>select target
5346853485
selectedoption elements</span>, run <span>clone an option into a selectedoption</span> given
5346953486
<var>option</var> and <var>selectedoption</var>.</p></li>
5347053487
</ol>
@@ -53520,7 +53537,7 @@ interface <dfn interface>HTMLSelectElement</dfn> : <span>HTMLElement</span> {
5352053537
data-x="concept-option-selectedness">selectedness</span> set to true, or null if there is no such
5352153538
<code>option</code>.</p></li>
5352253539

53523-
<li><p>For each <var>selectedoption</var> in <var>element</var>'s <span>select descendant
53540+
<li><p>For each <var>selectedoption</var> in <var>element</var>'s <span>select target
5352453541
selectedoption elements</span>, run <span>clone an option into a selectedoption</span> given
5352553542
<var>option</var> and <var>selectedoption</var>.</p></li>
5352653543
</ol>
@@ -53805,7 +53822,7 @@ interface <dfn interface>HTMLSelectElement</dfn> : <span>HTMLElement</span> {
5380553822
data-x="concept-option-selectedness">selectedness</span> to true and its <span
5380653823
data-x="concept-option-dirtiness">dirtiness</span> to true.
5380753824

53808-
<li><p>For each <var>selectedoption</var> in <var>select</var>'s <span>select descendant
53825+
<li><p>For each <var>selectedoption</var> in <var>select</var>'s <span>select target
5380953826
selectedoption elements</span>, run <span>clone an option into a selectedoption</span> given
5381053827
<var>option</var> and <var>selectedoption</var>.</p></li>
5381153828
</ol>
@@ -53928,6 +53945,64 @@ interface <dfn interface>HTMLSelectElement</dfn> : <span>HTMLElement</span> {
5392853945
&hellip;</code></pre>
5392953946
</div>
5393053947

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

5393254007

5393354008
<h4>The <dfn element><code>datalist</code></dfn> element</h4>
@@ -54299,7 +54374,7 @@ interface <dfn interface>HTMLOptionElement</dfn> : <span>HTMLElement</span> {
5429954374
data-x="dom-option-label">label</span>.</p></li>
5430054375

5430154376
<li>
54302-
<p>For each <var>selectedoption</var> of <var>select</var>'s <span>select descendant
54377+
<p>For each <var>selectedoption</var> of <var>select</var>'s <span>select target
5430354378
selectedoption elements</span>:</p>
5430454379

5430554380
<ol>

0 commit comments

Comments
 (0)