Skip to content

Commit d341596

Browse files
committed
Add selectedoptionattribute for <select> elements
1 parent d146704 commit d341596

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>
@@ -53454,6 +53456,21 @@ interface <dfn interface>HTMLSelectElement</dfn> : <span>HTMLElement</span> {
5345453456
<p>Every <code>select</code> element has <dfn>select descendant selectedoption elements</dfn>,
5345553457
which is a <span>list</span> of <code>selectedoption</code> elements, initially « ».</p>
5345653458

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

5351453531
<li><p><span>Send <code>select</code> update notifications</span>.</p></li>
5351553532

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

53572-
<li><p>For each <var>selectedoption</var> in <var>element</var>'s <span>select descendant
53589+
<li><p>For each <var>selectedoption</var> in <var>element</var>'s <span>select target
5357353590
selectedoption elements</span>, run <span>clone an option into a selectedoption</span> given
5357453591
<var>option</var> and <var>selectedoption</var>.</p></li>
5357553592
</ol>
@@ -53904,7 +53921,7 @@ interface <dfn interface>HTMLSelectElement</dfn> : <span>HTMLElement</span> {
5390453921
data-x="concept-option-selectedness">selectedness</span> to true and its <span
5390553922
data-x="concept-option-dirtiness">dirtiness</span> to true.
5390653923

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

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

5403154106

5403254107
<h4>The <dfn element><code>datalist</code></dfn> element</h4>
@@ -54428,7 +54503,7 @@ interface <dfn interface>HTMLOptionElement</dfn> : <span>HTMLElement</span> {
5442854503
data-x="dom-option-label">label</span>.</p></li>
5442954504

5443054505
<li>
54431-
<p>For each <var>selectedoption</var> of <var>select</var>'s <span>select descendant
54506+
<p>For each <var>selectedoption</var> of <var>select</var>'s <span>select target
5443254507
selectedoption elements</span>:</p>
5443354508

5443454509
<ol>

0 commit comments

Comments
 (0)