Skip to content

Commit fed19dc

Browse files
committed
Add selectedoptionattribute for <select> elements
1 parent a744e16 commit fed19dc

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

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

53467+
<p>To get the <dfn>select target selectedoption elements</dfn>, given a <code>select</code>
53468+
<var>select</var>:</p>
53469+
53470+
<ol>
53471+
<li><p>Let <var>selectedoptions</var> be <var>select</var>'s <span>select descendant
53472+
selectedoption elements</span>.</p></li>
53473+
53474+
<!-- TODO dom-selectedoptionelement can likely be overriden by script, but the "limited to only
53475+
known values" getter steps don't seem callable either. -->
53476+
<li><p><span data-x="list append">Append</span> the value of <var>select</var>'s <code
53477+
data-x="dom-selectedoptionelement">selectedOptionElement</code>, if it is non-null.</p></li>
53478+
53479+
<li><p>Return <var>selectedoptions</var>.</p></li>
53480+
</ol>
53481+
5346553482
<p>The <dfn element-attr for="select"><code data-x="attr-select-required">required</code></dfn>
5346653483
attribute is a <span>boolean attribute</span>. When specified, the user will be required to select
5346753484
a value before submitting the form.</p>
@@ -53521,7 +53538,7 @@ interface <dfn interface>HTMLSelectElement</dfn> : <span>HTMLElement</span> {
5352153538

5352253539
<li><p><span>Send <code>select</code> update notifications</span>.</p></li>
5352353540

53524-
<li><p>For each <var>selectedoption</var> in <var>select</var>'s <span>select descendant
53541+
<li><p>For each <var>selectedoption</var> in <var>select</var>'s <span>select target
5352553542
selectedoption elements</span>, run <span>clone an option into a selectedoption</span> given
5352653543
<var>option</var> and <var>selectedoption</var>.</p></li>
5352753544
</ol>
@@ -53577,7 +53594,7 @@ interface <dfn interface>HTMLSelectElement</dfn> : <span>HTMLElement</span> {
5357753594
data-x="concept-option-selectedness">selectedness</span> set to true, or null if there is no such
5357853595
<code>option</code>.</p></li>
5357953596

53580-
<li><p>For each <var>selectedoption</var> in <var>element</var>'s <span>select descendant
53597+
<li><p>For each <var>selectedoption</var> in <var>element</var>'s <span>select target
5358153598
selectedoption elements</span>, run <span>clone an option into a selectedoption</span> given
5358253599
<var>option</var> and <var>selectedoption</var>.</p></li>
5358353600
</ol>
@@ -53915,7 +53932,7 @@ interface <dfn interface>HTMLSelectElement</dfn> : <span>HTMLElement</span> {
5391553932
data-x="concept-option-selectedness">selectedness</span> to true and its <span
5391653933
data-x="concept-option-dirtiness">dirtiness</span> to true.
5391753934

53918-
<li><p>For each <var>selectedoption</var> in <var>select</var>'s <span>select descendant
53935+
<li><p>For each <var>selectedoption</var> in <var>select</var>'s <span>select target
5391953936
selectedoption elements</span>, run <span>clone an option into a selectedoption</span> given
5392053937
<var>option</var> and <var>selectedoption</var>.</p></li>
5392153938
</ol>
@@ -54038,6 +54055,64 @@ interface <dfn interface>HTMLSelectElement</dfn> : <span>HTMLElement</span> {
5403854055
&hellip;</code></pre>
5403954056
</div>
5404054057

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

5404254117

5404354118
<h4>The <dfn element><code>datalist</code></dfn> element</h4>
@@ -54439,7 +54514,7 @@ interface <dfn interface>HTMLOptionElement</dfn> : <span>HTMLElement</span> {
5443954514
data-x="dom-option-label">label</span>.</p></li>
5444054515

5444154516
<li>
54442-
<p>For each <var>selectedoption</var> of <var>select</var>'s <span>select descendant
54517+
<p>For each <var>selectedoption</var> of <var>select</var>'s <span>select target
5444354518
selectedoption elements</span>:</p>
5444454519

5444554520
<ol>

0 commit comments

Comments
 (0)