Skip to content

Commit 16c2d7d

Browse files
committed
Factor out find a named element and rename a collection's nodes
1 parent 5796f71 commit 16c2d7d

1 file changed

Lines changed: 35 additions & 28 deletions

File tree

dom.bs

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3820,11 +3820,11 @@ the data.
38203820
When a <a>collection</a> is created, a
38213821
filter and a root are associated with it.
38223822

3823-
The <a>collection</a> then
3824-
<dfn export for=collection lt="represented by the collection" id=represented-by-the-collection>represents</dfn>
3825-
a view of the subtree rooted at the <a>collection's</a> root, containing only nodes that match the
3826-
given filter. The view is linear. In the absence of specific requirements to the contrary, the nodes
3827-
within the <a>collection</a> must be sorted in <a>tree order</a>.
3823+
A <a>collection</a>'s
3824+
<dfn export for=collection lt="nodes|elements" id=represented-by-the-collection>nodes</dfn>
3825+
are the <a for=/>nodes</a>, in the subtree rooted at the <a>collection's</a> root, that match the
3826+
given filter. This is a linear view; in the absence of specific requirements to the contrary, the
3827+
<a for=/>nodes</a> are sorted in <a>tree order</a>.
38283828

38293829

38303830
<h5 id=interface-nodelist>Interface {{NodeList}}</h5>
@@ -3851,16 +3851,15 @@ interface NodeList {
38513851
</dl>
38523852

38533853
<p>The object's <a>supported property indices</a> are the numbers in the range zero to one less than
3854-
the number of nodes <a for=collection>represented by the collection</a>. If there are no such
3855-
elements, then there are no <a>supported property indices</a>.
3854+
the size of the <a>collection</a>'s <a for=collection>nodes</a>. If that size is zero, then there
3855+
are no <a>supported property indices</a>.
38563856

3857-
<p>The <dfn attribute for=NodeList>length</dfn> attribute must return the number of nodes
3858-
<a for=collection>represented by the collection</a>.
3857+
<p>The <dfn attribute for=NodeList>length</dfn> getter steps are to return the size of
3858+
<a>this</a>'s <a for=collection>nodes</a>.
38593859

3860-
<p>The <dfn method for=NodeList><code>item(<var>index</var>)</code></dfn> method must return the
3861-
<var>index</var><sup>th</sup> <a for=/>node</a> in the <a>collection</a>. If there is no
3862-
<var>index</var><sup>th</sup> <a for=/>node</a> in the <a>collection</a>, then the method must
3863-
return null.
3860+
<p>The <dfn method for=NodeList><code>item(<var>index</var>)</code></dfn> method steps are to return
3861+
the <var>index</var><sup>th</sup> <a for=/>node</a> in <a>this</a>'s <a for=collection>nodes</a>, or
3862+
null if there is no such <a for=/>node</a>.
38643863

38653864

38663865
<h5 id=interface-htmlcollection>Interface {{HTMLCollection}}</h5>
@@ -3901,25 +3900,23 @@ it (use <code>sequence&lt;T></code> in IDL instead).
39013900
</dl>
39023901

39033902
<p>The object's <a>supported property indices</a> are the numbers in the range zero to one less than
3904-
the number of elements <a for=collection>represented by the collection</a>. If there are no such
3905-
elements, then there are no <a>supported property indices</a>.
3903+
the size of the <a>collection</a>'s <a for=collection>elements</a>. If that size is zero, then there
3904+
are no <a>supported property indices</a>.
39063905

39073906
<p>The <dfn attribute for=HTMLCollection><code>length</code></dfn> getter steps are to return the
3908-
number of nodes <a for=collection>represented by the collection</a>.
3907+
size of <a>this</a>'s <a for=collection>elements</a>.
39093908

39103909
<p>The <dfn method for=HTMLCollection><code>item(<var>index</var>)</code></dfn> method steps are to
3911-
return the <var>index</var><sup>th</sup> <a for=/>element</a> in the <a>collection</a>. If there
3912-
is no <var>index</var><sup>th</sup> <a for=/>element</a> in the <a>collection</a>, then the method
3913-
must return null.
3910+
return the <var>index</var><sup>th</sup> <a for=/>element</a> in <a>this</a>'s
3911+
<a for=collection>elements</a>, or null if there is no such <a for=/>element</a>.
39143912

39153913
<p>The <a>supported property names</a> are the values from the list returned by these steps:
39163914

39173915
<ol>
39183916
<li><p>Let <var>result</var> be an empty list.
39193917

39203918
<li>
3921-
<p>For each <var>element</var> <a for=collection>represented by the collection</a>, in
3922-
<a>tree order</a>:
3919+
<p>For each <var>element</var> of <a>this</a>'s <a for=collection>elements</a>:
39233920

39243921
<ol>
39253922
<li><p>If <var>element</var> has an <a for=Element>ID</a> which is not in <var>result</var>,
@@ -3935,25 +3932,35 @@ must return null.
39353932
<li><p>Return <var>result</var>.
39363933
</ol>
39373934

3938-
<p>The <dfn method for=HTMLCollection><code>namedItem(<var>key</var>)</code></dfn> method steps are:
3935+
<div algorithm>
3936+
<p>To <dfn export>find a named element</dfn> in a
3937+
<a for=/>list</a> of <a for=/>elements</a> <var>elements</var> given a string <var>key</var>:
39393938

39403939
<ol>
3941-
<li><p>If <var>key</var> is the empty string, return null.
3940+
<li><p>If <var>key</var> is the empty string, then return null.
39423941

39433942
<li>
3944-
<p>Return the first <a for=/>element</a> in the <a>collection</a> for which at least one of
3945-
the following is true:
3943+
<p>If <var>elements</var> contains an <a for=/>element</a> for which one of the following is
3944+
true:
39463945

39473946
<ul>
3948-
<li>it has an <a for=Element>ID</a> which is <var>key</var>;
3947+
<li>its <a for=Element>ID</a> is <var>key</var>; or
39493948

39503949
<li>it is in the <a>HTML namespace</a> and <a lt="has an attribute">has</a> a
39513950
<a lt="named attribute"><code>name</code> attribute</a> whose <a for=Attr>value</a> is
3952-
<var>key</var>;
3951+
<var>key</var>,
39533952
</ul>
39543953

3955-
<p>or null if there is no such <a for=/>element</a>.
3954+
<p>then return the first such <a for=/>element</a>.
3955+
3956+
<li><p>Return null.
39563957
</ol>
3958+
</div>
3959+
3960+
<div algorithm>
3961+
<p>The <dfn method for=HTMLCollection><code>namedItem(<var>key</var>)</code></dfn> method steps are
3962+
to <a>find a named element</a> in <a>this</a>'s <a for=collection>elements</a> given <var>key</var>.
3963+
</div>
39573964

39583965

39593966

0 commit comments

Comments
 (0)