Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
151 changes: 94 additions & 57 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -9820,8 +9820,8 @@ interface <dfn interface>HTMLOptionsCollection</dfn> : <span>HTMLCollection</spa

<li><p>Let <var>n</var> be <var>value</var> &minus; <var>current</var>.</p></li>

<li><p>Append <var>n</var> new <code>option</code> elements with no attributes and no child
nodes to the <code>select</code> element on which <span>this</span> is rooted.</p></li>
<li><p><span>Append new option elements</span> to the <code>select</code> element on which
<span>this</span> is rooted given <var>n</var>.</p></li>
</ol>
</li>

Expand Down Expand Up @@ -9851,73 +9851,88 @@ interface <dfn interface>HTMLOptionsCollection</dfn> : <span>HTMLCollection</spa
</div>

<div algorithm>
<p id="dom-htmloptionscollection-setter">When the user agent is to <span>set the value of a new
indexed property</span> or <span>set the value of an existing indexed property</span> for a given
property index <var>index</var> to a new value <var>value</var>, it must run the following
algorithm:</p>
<p>To <dfn>append new option elements</dfn> to a <code>select</code> element
<var>select</var> given a non-negative integer <var>count</var>:</p>

<ol>
<li><p>If <var>value</var> is null, invoke the steps for the <code
data-x="dom-HTMLOptionsCollection-remove">remove</code> method with <var>index</var> as
the argument, and return.</p></li>
<li><p>Let <var>fragment</var> be a new <code>DocumentFragment</code> whose <span>node
document</span> is <var>select</var>'s <span>node document</span>.</p></li>

<li><p>Let <var>length</var> be the number of nodes <span>represented by the
collection</span>.</p></li>
<li><p>Append <var>count</var> new <code>option</code> elements to <var>fragment</var>.</p></li>

<li><p><span data-x="concept-node-append">Append</span> <var>fragment</var> to
<var>select</var>.</p></li>
</ol>
</div>

<div algorithm>
<p id="dom-htmloptionscollection-setter">To <span>set the value of a new indexed property</span>
or <span>set the value of an existing indexed property</span> for an
<code>HTMLOptionsCollection</code> <var>collection</var>, given a property index <var>index</var>
and a new value <var>value</var>:</p>

<ol>
<li><p>If <var>value</var> is null, then <span data-x="HTMLOptionsCollection-remove-an-option">remove
an option</span> from <var>collection</var> given <var>index</var> and return.</p></li>

<li><p>Let <var>length</var> be the number of nodes <span data-x="represented by the
collection">represented</span> by <var>collection</var>.</p></li>

<li><p>Let <var>delta</var> be <var>index</var> minus <var>length</var>.</p></li>
<li><p>Let <var>delta</var> be <var>index</var> &minus; <var>length</var>.</p></li>

<li><p>If <var>delta</var> is greater than zero, then <span
data-x="concept-node-append">append</span> a <code>DocumentFragment</code> consisting of
<var>delta</var> new <code>option</code> elements with no attributes and
no child nodes to the <code>select</code> element on which the <code>HTMLOptionsCollection</code>
is rooted.</p></li>
<li><p>If <var>delta</var> is greater than 0, then <span>append new option elements</span> to
the <code>select</code> element on which <var>collection</var> is rooted given
<var>delta</var>.</p></li>

<li><p>If <var>delta</var> is greater than or equal to zero, <span
data-x="concept-node-append">append</span> <var>value</var> to the <code>select</code>
element. Otherwise, <span data-x="concept-node-replace">replace</span> the <var>index</var>th element in the collection by <var>value</var>.</p></li>
<li><p>If <var>delta</var> is greater than or equal to 0, then <span
data-x="concept-node-append">append</span> <var>value</var> to the <code>select</code> element
on which <var>collection</var> is rooted. Otherwise, <span
data-x="concept-node-replace">replace</span> the <var>index</var>th element in
<var>collection</var> by <var>value</var>.</p></li>
</ol>
</div>

<div algorithm>
<p>The <dfn method for="HTMLOptionsCollection"><code
data-x="dom-HTMLOptionsCollection-add">add(<var>element</var>, <var>before</var>)</code></dfn>
method must act according to the following algorithm:</p>
method steps are:</p>

<ol>
<li><p>If <var>element</var> is an ancestor of the <code>select</code> element on which
the <code>HTMLOptionsCollection</code> is rooted, then throw a
<span>"<code>HierarchyRequestError</code>"</span> <code>DOMException</code>.</li>
<span>this</span> is rooted, then throw a <span>"<code>HierarchyRequestError</code>"</span>
<code>DOMException</code>.</p></li>

<li><p>If <var>before</var> is an element, but that element isn't a descendant of the
<code>select</code> element on which the <code>HTMLOptionsCollection</code> is rooted, then throw
a <span>"<code>NotFoundError</code>"</span> <code>DOMException</code>.</p></li>
<code>select</code> element on which <span>this</span> is rooted, then throw a
<span>"<code>NotFoundError</code>"</span> <code>DOMException</code>.</p></li>

<li><p>If <var>element</var> and <var>before</var> are the same element, then return.</p></li>

<li><p>If <var>element</var> and <var>before</var> are the same element, then
return.</li>
<li><p>Let <var>reference</var> be null.</p></li>

<li><p>If <var>before</var> is a node, then let <var>reference</var> be that
node. Otherwise, if <var>before</var> is an integer, and there is a <var>before</var>th node in the collection, let <var>reference</var> be that node.
Otherwise, let <var>reference</var> be null.</p></li>
<li><p>If <var>before</var> is a node, then set <var>reference</var> to <var>before</var>.
Otherwise, if <var>before</var> is an integer and there is a <var>before</var>th node in
<span>this</span>, then set <var>reference</var> to that node.</p></li>

<li><p>If <var>reference</var> is not null, let <var>parent</var> be the parent
node of <var>reference</var>. Otherwise, let <var>parent</var> be the
<code>select</code> element on which the <code>HTMLOptionsCollection</code> is rooted.</p></li>
<li><p>Let <var>parent</var> be <var>reference</var>'s parent node if <var>reference</var> is
not null; otherwise the <code>select</code> element on which <span>this</span> is rooted.</p></li>

<li><p><span>Pre-insert</span> <var>element</var> into <var>parent</var> node before
<var>reference</var>.</p>
<var>reference</var>.</p></li>
</ol>
</div>

<div algorithm>
<p>The <dfn method for="HTMLOptionsCollection"><code
data-x="dom-HTMLOptionsCollection-remove">remove(<var>index</var>)</code></dfn> method must act
according to the following algorithm:</p>
<p>To <dfn data-x="HTMLOptionsCollection-remove-an-option">remove an option</dfn> from an
<code>HTMLOptionsCollection</code> <var>collection</var> given an integer <var>index</var>:</p>

<ol>
<li><p>If the number of nodes <span>represented by the collection</span> is zero, return.</li>
<li><p>If the number of nodes <span data-x="represented by the collection">represented</span> by
<var>collection</var> is 0, then return.</p></li>

<li><p>If <var>index</var> is not a number greater than or equal to 0 and less than the
number of nodes <span>represented by the collection</span>, return.</p></li>
<li><p>If <var>index</var> is not a number greater than or equal to 0 and less than the number
of nodes <span data-x="represented by the collection">represented</span> by <var>collection</var>,
then return.</p></li>
<!-- note that Web IDL converts 'a', NaN, -0.5, 0.5, most objects, and null to 0, and numbers in
general truncate. so what we're checking against here in a way has very little to do with what's
going on in the JS -->
Expand All @@ -9931,18 +9946,31 @@ interface <dfn interface>HTMLOptionsCollection</dfn> : <span>HTMLCollection</spa
https://software.hixie.ch/utilities/js/live-dom-viewer/?saved=2827
-->

<li><p>Let <var>element</var> be the <var>index</var>th element in the
collection.</p></li>
<li><p>Let <var>element</var> be the <var>index</var>th element in
<var>collection</var>.</p></li>

<li><p>Remove <var>element</var> from its parent node.</p></li>
</ol>
</div>

<div algorithm>
<p>The <dfn method for="HTMLOptionsCollection"><code
data-x="dom-HTMLOptionsCollection-remove">remove(<var>index</var>)</code></dfn> method steps are
to <span data-x="HTMLOptionsCollection-remove-an-option">remove an option</span> from
<span>this</span> given <var>index</var>.</p>
</div>

<div algorithm>
<p>The <dfn attribute for="HTMLOptionsCollection"><code
data-x="dom-HTMLOptionsCollection-selectedIndex">selectedIndex</code></dfn> IDL attribute must act
like the identically named attribute on the <code>select</code> element on which the
<code>HTMLOptionsCollection</code> is rooted</p>
data-x="dom-HTMLOptionsCollection-selectedIndex">selectedIndex</code></dfn> getter steps are to
return the <span data-x="select-selected-index">selected index</span> of the <code>select</code>
element on which <span>this</span> is rooted.</p>
</div>

<div algorithm>
<p>The <code data-x="dom-HTMLOptionsCollection-selectedIndex">selectedIndex</code> setter steps
are to <span>set the selected index</span> of the <code>select</code> element on which
<span>this</span> is rooted to the given value.</p>
</div>

<!-- see also https://ln.hixie.ch/?start=1161042744&count=1 -->
Expand Down Expand Up @@ -57370,31 +57398,29 @@ interface <dfn interface>HTMLSelectElement</dfn> : <span>HTMLElement</span> {
<span data-x="concept-option-selectedness">selectedness</span> set to true.</p>
</div>

<div algorithm>
<p>The <dfn attribute for="HTMLSelectElement"><code
data-x="dom-select-selectedIndex">selectedIndex</code></dfn> getter steps are to return the <span
data-x="concept-option-index">index</span> of the first <code>option</code> element in
<span>this</span>'s <span data-x="concept-select-option-list">list of options</span> in <span>tree
order</span> that has its <span data-x="concept-option-selectedness">selectedness</span> set to
true, if any. If there isn't one, then return &#x2212;1.</p>
</div>
<p>A <code>select</code> element's <dfn data-x="select-selected-index">selected index</dfn> is
the <span data-x="concept-option-index">index</span> of the first <code>option</code> element in
its <span data-x="concept-select-option-list">list of options</span> in <span>tree order</span>
that has its <span data-x="concept-option-selectedness">selectedness</span> set to true. If there
isn't one, then it is &#x2212;1.</p>

<div algorithm>
<p>The <code data-x="dom-select-selectedIndex">selectedIndex</code> setter steps are:</p>
<p>To <dfn>set the selected index</dfn> of a <code>select</code> element
<var>select</var> to a value <var>value</var>:</p>

<ol>
<li><p>Let <var>firstMatchingOption</var> be null.</p></li>

<li>
<p>For each <var>option</var> of <span>this</span>'s <span
<p>For each <var>option</var> of <var>select</var>'s <span
data-x="concept-select-option-list">list of options</span>:</p>

<ol>
<li><p>Set <var>option</var>'s <span data-x="concept-option-selectedness">selectedness</span>
to false.</p></li>

<li><p>If <var>firstMatchingOption</var> is null and <var>option</var>'s <span
data-x="concept-option-index">index</span> is equal to the given value, then set
data-x="concept-option-index">index</span> is equal to <var>value</var>, then set
<var>firstMatchingOption</var> to <var>option</var>.</p></li>
</ol>
</li>
Expand All @@ -57405,7 +57431,7 @@ interface <dfn interface>HTMLSelectElement</dfn> : <span>HTMLElement</span> {
true.</p></li>

<li><p>Run <span>update a <code>select</code>'s <code>selectedcontent</code></span> given
<span>this</span>.</p></li>
<var>select</var>.</p></li>
</ol>
</div>

Expand All @@ -57414,6 +57440,17 @@ interface <dfn interface>HTMLSelectElement</dfn> : <span>HTMLElement</span> {
<code>select</code> element having no <code data-x="attr-select-multiple">multiple</code>
attribute and a <span data-x="concept-select-size">display size</span> of 1.</p>

<div algorithm>
<p>The <dfn attribute for="HTMLSelectElement"><code
data-x="dom-select-selectedIndex">selectedIndex</code></dfn> getter steps are to return
<span>this</span>'s <span data-x="select-selected-index">selected index</span>.</p>
</div>

<div algorithm>
<p>The <code data-x="dom-select-selectedIndex">selectedIndex</code> setter steps are to <span>set
the selected index</span> of <span>this</span> to the given value.</p>
</div>

<div algorithm>
<p>The <dfn attribute for="HTMLSelectElement"><code data-x="dom-select-value">value</code></dfn>
getter steps are to return the <span data-x="concept-option-value">value</span> of the
Expand Down
Loading