Skip to content

Commit ec4196a

Browse files
authored
Specify a limit for HTMLOptionsCollection's length setter
This aligns with WebKit's behavior, but bumps the limit to 100k from WebKit's 10k, as per the discussion in #8337. Closes #8337.
1 parent 51a7611 commit ec4196a

File tree

1 file changed

+38
-13
lines changed

1 file changed

+38
-13
lines changed

source

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8374,8 +8374,9 @@ interface <dfn interface>HTMLOptionsCollection</dfn> : <span>HTMLCollection</spa
83748374
<p>When set to a smaller number than the existing length, truncates the number of
83758375
<code>option</code> elements in the container corresponding to <var>collection</var>.</p>
83768376

8377-
<p>When set to a greater number than the existing length, adds new blank <code>option</code>
8378-
elements to the container corresponding to <var>collection</var>.</p>
8377+
<p>When set to a greater number than the existing length, if that number is less than or equal
8378+
to 100000, adds new blank <code>option</code> elements to the container corresponding to
8379+
<var>collection</var>.</p>
83798380
</dd>
83808381

83818382
<dt><code data-x=""><var>element</var> = <var>collection</var>.<span data-x="dom-HTMLCollection-item">item</span>(<var>index</var>)</code></dt>
@@ -8435,17 +8436,41 @@ interface <dfn interface>HTMLOptionsCollection</dfn> : <span>HTMLCollection</spa
84358436
<p>The object's <span>supported property indices</span> are as defined for
84368437
<code>HTMLCollection</code> objects.</p>
84378438

8438-
<p>On getting, the <dfn attribute for="HTMLOptionsCollection"><code
8439-
data-x="dom-HTMLOptionsCollection-length">length</code></dfn> attribute must return the number of
8440-
nodes <span>represented by the collection</span>.</p>
8441-
8442-
<p>On setting, the behavior depends on whether the new value is equal to, greater than, or less
8443-
than the number of nodes <span>represented by the collection</span> at that time. If the number is
8444-
the same, then setting the attribute must do nothing. If the new value is greater, then <var>n</var> new <code>option</code> elements with no attributes and no child nodes must be
8445-
appended to the <code>select</code> element on which the <code>HTMLOptionsCollection</code> is
8446-
rooted, where <var>n</var> is the difference between the two numbers (new value minus old
8447-
value). Mutation events must be fired as if a <code>DocumentFragment</code> containing the new
8448-
<code>option</code> elements had been inserted. If the new value is lower, then the last <var>n</var> nodes in the collection must be removed from their parent nodes, where <var>n</var> is the difference between the two numbers (old value minus new value).</p>
8439+
<p>The <dfn attribute for="HTMLOptionsCollection"><code
8440+
data-x="dom-HTMLOptionsCollection-length">length</code></dfn> getter steps are to return the
8441+
number of nodes <span>represented by the collection</span>.</p>
8442+
8443+
<p>The <code data-x="dom-HTMLOptionsCollection-length">length</code> setter steps are:</p>
8444+
8445+
<ol>
8446+
<li><p>Let <var>current</var> be the number of nodes <span>represented by the
8447+
collection</span>.</p></li>
8448+
8449+
<li>
8450+
<p>If the given value is greater than <var>current</var>, then:</p>
8451+
8452+
<ol>
8453+
<li><p>If the given value is greater than 100,000, then return.</p></li>
8454+
8455+
<li><p>Let <var>n</var> be <var>value</var> &minus; <var>current</var>.</p></li>
8456+
8457+
<li><p>Append <var>n</var> new <code>option</code> elements with no attributes and no child
8458+
nodes to the <code>select</code> element on which <span>this</span> is rooted. Mutation events
8459+
must be fired as if a <code>DocumentFragment</code> containing the new <code>option</code>
8460+
elements had been inserted.</p></li>
8461+
</ol>
8462+
</li>
8463+
8464+
<li>
8465+
<p>If the given value is less than <var>current</var>, then:</p>
8466+
8467+
<ol>
8468+
<li><p>Let <var>n</var> be <var>current</var> &minus; <var>value</var>.</p></li>
8469+
8470+
<li><p>Remove the last <var>n</var> nodes in the collection from their parent nodes.</p></li>
8471+
</ol>
8472+
</li>
8473+
</ol>
84498474

84508475
<p class="note">Setting <code data-x="dom-HTMLOptionsCollection-length">length</code> never removes
84518476
or adds any <code>optgroup</code> elements, and never adds new children to existing

0 commit comments

Comments
 (0)