Skip to content

Commit 34be830

Browse files
committed
Add selectedoptionattribute for <select> elements
1 parent bef9083 commit 34be830

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

5338353383
readonly attribute <span>NodeList</span> <span data-x="dom-lfe-labels">labels</span>;
53384+
53385+
attribute <code data-x="selectedoption">HTMLSelectedOptionElement</code>? <span data-x="dom-selectedoptionelement">selectedOptionElement</span>;
5338453386
};</code></pre>
5338553387
</dd>
5338653388
<dd w-dev>Uses <code>HTMLSelectElement</code>.</dd>
@@ -53450,6 +53452,21 @@ interface <dfn interface>HTMLSelectElement</dfn> : <span>HTMLElement</span> {
5345053452
<p>Every <code>select</code> element has <dfn>select descendant selectedoption elements</dfn>,
5345153453
which is a <span>list</span> of <code>selectedoption</code> elements, initially « ».</p>
5345253454

53455+
<p>To get the <dfn>select target selectedoption elements</dfn>, given a <code>select</code>
53456+
<var>select</var>:</p>
53457+
53458+
<ol>
53459+
<li><p>Let <var>selectedoptions</var> be <var>select</var>'s <span>select descendant
53460+
selectedoption elements</span>.</p></li>
53461+
53462+
<!-- TODO dom-selectedoptionelement can likely be overriden by script, but the "limited to only
53463+
known values" getter steps don't seem callable either. -->
53464+
<li><p><span data-x="list append">Append</span> the value of <var>select</var>'s <code
53465+
data-x="dom-selectedoptionelement">selectedOptionElement</code>, if it is non-null.</p></li>
53466+
53467+
<li><p>Return <var>selectedoptions</var>.</p></li>
53468+
</ol>
53469+
5345353470
<p>The <dfn element-attr for="select"><code data-x="attr-select-required">required</code></dfn>
5345453471
attribute is a <span>boolean attribute</span>. When specified, the user will be required to select
5345553472
a value before submitting the form.</p>
@@ -53509,7 +53526,7 @@ interface <dfn interface>HTMLSelectElement</dfn> : <span>HTMLElement</span> {
5350953526

5351053527
<li><p><span>Send <code>select</code> update notifications</span>.</p></li>
5351153528

53512-
<li><p>For each <var>selectedoption</var> in <var>select</var>'s <span>select descendant
53529+
<li><p>For each <var>selectedoption</var> in <var>select</var>'s <span>select target
5351353530
selectedoption elements</span>, run <span>clone an option into a selectedoption</span> given
5351453531
<var>option</var> and <var>selectedoption</var>.</p></li>
5351553532
</ol>
@@ -53565,7 +53582,7 @@ interface <dfn interface>HTMLSelectElement</dfn> : <span>HTMLElement</span> {
5356553582
data-x="concept-option-selectedness">selectedness</span> set to true, or null if there is no such
5356653583
<code>option</code>.</p></li>
5356753584

53568-
<li><p>For each <var>selectedoption</var> in <var>element</var>'s <span>select descendant
53585+
<li><p>For each <var>selectedoption</var> in <var>element</var>'s <span>select target
5356953586
selectedoption elements</span>, run <span>clone an option into a selectedoption</span> given
5357053587
<var>option</var> and <var>selectedoption</var>.</p></li>
5357153588
</ol>
@@ -53903,7 +53920,7 @@ interface <dfn interface>HTMLSelectElement</dfn> : <span>HTMLElement</span> {
5390353920
data-x="concept-option-selectedness">selectedness</span> to true and its <span
5390453921
data-x="concept-option-dirtiness">dirtiness</span> to true.
5390553922

53906-
<li><p>For each <var>selectedoption</var> in <var>select</var>'s <span>select descendant
53923+
<li><p>For each <var>selectedoption</var> in <var>select</var>'s <span>select target
5390753924
selectedoption elements</span>, run <span>clone an option into a selectedoption</span> given
5390853925
<var>option</var> and <var>selectedoption</var>.</p></li>
5390953926
</ol>
@@ -54026,6 +54043,64 @@ interface <dfn interface>HTMLSelectElement</dfn> : <span>HTMLElement</span> {
5402654043
&hellip;</code></pre>
5402754044
</div>
5402854045

54046+
<h4>The <code data-x="attr-selectedoptionelement">selectedoptionelement</code> attribute</h4>
54047+
54048+
<p><code>select</code> elements may have the <dfn element-attr
54049+
for="select"><code data-x="attr-selectedoptionelement">selectedoptionelement</code></dfn>
54050+
attribute. When specified its value must be the <span data-x="concept-ID">ID</span> of a
54051+
<code>selectedoption</code> element in the same <span>tree</span> as the <code>select</code> with
54052+
the <code data-x="attr-selectedoptionelement">selectedoptionelement</code> attribute. The target
54053+
<code>selectedoption</code> will update its contents to match the currently selected
54054+
<code>option</code> of the <code>select</code>.</p>
54055+
54056+
<div class="example">
54057+
<p>The following code shows how the <code
54058+
data-x="attr-selectedoptionelement">selectedoptionelement</code> attribute can be used to render
54059+
a <code>select</code> element's value outside of the <code>select</code>:</p>
54060+
54061+
<pre><code class="html">&lt;label for="pet-select">Choose a pet:&lt;/label>
54062+
&lt;select id="pet-select" selectedoptionelement="summary-value">
54063+
&lt;option>dog&lt;/option>
54064+
&lt;option>cat&lt;/option>
54065+
&lt;/select>
54066+
&lt;p>Summary: you chose the &lt;selectedoption id="summary-value">&lt;/selectedoption>.&lt;p></code></pre>
54067+
</div>
54068+
54069+
<p>The <dfn attribute for="select"><code
54070+
data-x="dom-selectedoptionelement">selectedOptionElement</code></dfn> IDL attribute must
54071+
<span>reflect</span> the <code data-x="attr-selectedoptionelement">selectedoptionelement</code>
54072+
attribute, <span>limited to only known values</span>.</p>
54073+
54074+
<p>The following <span data-x="concept-element-attributes-change-ext">attribute change
54075+
steps</span> given <var>element</var>, <var>localName</var>, <var>oldValue</var>,
54076+
<var>value</var>, and <var>namespace</var>, are used for <code>select</code> elements:</p>
54077+
54078+
<ol>
54079+
<li><p>If <var>namespace</var> is not null, then return.</p></li>
54080+
54081+
<li><p>If <var>localName</var> is not <code
54082+
data-x="attr-selectedoptionelement">selectedoptionelement</code>, then return.</p></li>
54083+
54084+
<li><p>Let <var>oldSelectedoption</var> be the first <code>selectedoption</code> element in
54085+
<span>tree order</span> in <var>element</var>'s <span>root</span> whose <span
54086+
data-x="concept-ID">ID</span> is <var>oldValue</var> if one exists, otherwise null.</p></li>
54087+
54088+
<li><p>Let <var>newSelectedoption</var> be the first <code>selectedoption</code> element in
54089+
<span>tree order</span> in <var>element</var>'s <span>root</span> whose <span
54090+
data-x="concept-ID">ID</span> is <var>value</var> if one exists, otherwise null.</p></li>
54091+
54092+
<li><p>If <var>oldSelectedoption</var> is eequal to <var>newSelectedoption</var>, then
54093+
return.</p></li>
54094+
54095+
<li><p>If <var>oldSelectedoption</var> is not null, then run <span>clone an option into a
54096+
selectedoption</span> given null and <var>oldSelectedOption</var>.</p></li>
54097+
54098+
<li><p>If <var>newSelectedoption</var> is not null, then run <span>clone an option into a
54099+
selectedoption</span> given the value of <var>element</var>'s <code
54100+
data-x="dom-selectedoptionelement">selectedOptionElement</code> and
54101+
<var>newSelectedOption</var>.</p></li>
54102+
</ol>
54103+
5402954104

5403054105

5403154106
<h4>The <dfn element><code>datalist</code></dfn> element</h4>
@@ -54427,7 +54502,7 @@ interface <dfn interface>HTMLOptionElement</dfn> : <span>HTMLElement</span> {
5442754502
data-x="dom-option-label">label</span>.</p></li>
5442854503

5442954504
<li>
54430-
<p>For each <var>selectedoption</var> of <var>select</var>'s <span>select descendant
54505+
<p>For each <var>selectedoption</var> of <var>select</var>'s <span>select target
5443154506
selectedoption elements</span>:</p>
5443254507

5443354508
<ol>

0 commit comments

Comments
 (0)