Skip to content

Commit

Permalink
Fix #210: give HTMLAllCollection its own class
Browse files Browse the repository at this point in the history
This better matches browsers, and avoids the confusing inheritance which only applies to half of the item() method.
  • Loading branch information
domenic authored and annevk committed Oct 1, 2015
1 parent d95b36b commit 4bade08
Showing 1 changed file with 30 additions and 23 deletions.
53 changes: 30 additions & 23 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -2983,7 +2983,7 @@ a.setAttribute('href', 'http://example.com/'); // change the content attribute d
<li><dfn data-noexport=""><code data-x="dom-HTMLCollection-length">HTMLCollection.length</code></dfn> attribute</li>
<li><dfn data-noexport=""><code data-x="dom-HTMLCollection-item">HTMLCollection.item()</code></dfn> method</li>
<li><dfn data-noexport=""><code data-x="dom-HTMLCollection-namedItem">HTMLCollection.namedItem()</code></dfn> method</li>
<li>The terms <dfn data-noexport="">collections</dfn> and <dfn data-noexport="">represented by the collection</dfn></li>
<li>The terms <dfn data-noexport="" data-x="concept-collection">collection</dfn> and <dfn data-noexport="">represented by the collection</dfn></li>

<li><dfn data-noexport=""><code>DOMTokenList</code></dfn> interface</li>
<li><dfn data-noexport=""><code>DOMSettableTokenList</code></dfn> interface</li>
Expand Down Expand Up @@ -7057,9 +7057,10 @@ a.setAttribute('href', 'http://example.com/'); // change the content attribute d
<!--TOPIC:DOM APIs-->
<h4>Collections</h4>

<p>The <code>HTMLAllCollection</code>, <code>HTMLFormControlsCollection</code>, and
<code>HTMLOptionsCollection</code> interfaces are <span>collections</span> derived from the
<code>HTMLCollection</code> interface.</p>
<p>The <code>HTMLFormControlsCollection</code> and <code>HTMLOptionsCollection</code> interfaces
are <span data-x="concept-collection">collections</span> derived from the
<code>HTMLCollection</code> interface. The <code>HTMLAllCollection</code> interface is a <span
data-x="concept-collection">collection</span>, but is not so derived.</p>


<h5>The <code>HTMLAllCollection</code> interface</h5>
Expand All @@ -7077,22 +7078,22 @@ a.setAttribute('href', 'http://example.com/'); // change the content attribute d
collection</span> of an <code>HTMLAllCollection</code> object consist of all the descendant
elements of the root <code>Document</code>.</p>

<pre class="idl">interface <dfn>HTMLAllCollection</dfn> : <span>HTMLCollection</span> {
// inherits <span data-x="dom-HTMLCollection-length">length</span> and 'getter'
<span>Element</span>? <span data-x="dom-HTMLAllCollection-item">item</span>(unsigned long index);
<pre class="idl">interface <dfn>HTMLAllCollection</dfn> {
readonly attribute unsigned long <span data-x="dom-HTMLAllCollection-length">length</span>;
getter <span>Element</span>? <span data-x="dom-HTMLAllCollection-item">item</span>(unsigned long index);
(<span>HTMLCollection</span> or <span>Element</span>)? <span data-x="dom-HTMLAllCollection-item-string">item</span>(DOMString name);
legacycaller getter (<span>HTMLCollection</span> or <span>Element</span>)? <span data-x="dom-HTMLAllCollection-namedItem">namedItem</span>(DOMString name); // shadows inherited <span data-x="dom-HTMLCollection-namedItem">namedItem()</span>
legacycaller getter (<span>HTMLCollection</span> or <span>Element</span>)? <span data-x="dom-HTMLAllCollection-namedItem">namedItem</span>(DOMString name);
};</pre>

<dl class="domintro">

<dt><var>collection</var> . <code subdfn data-x="dom-HTMLCollection-length">length</code></dt>
<dt><var>collection</var> . <code subdfn data-x="dom-HTMLAllCollection-length">length</code></dt>
<dd>
<p>Returns the number of elements in the collection.</p>
</dd>

<dt><var>element</var> = <var>collection</var> . <code subdfn data-x="dom-HTMLAllCollection-item">item</code>(<var>index</var>)</dt>
<dt><var>collection</var>[<var>index</var>]</dt>
<dt><var>element</var> = <var>collection</var>[<var>index</var>]</dt>
<dd>
<p>Returns the item with index <var>index</var> from the collection. The items are sorted in <span>tree order</span>.</p>
</dd>
Expand All @@ -7103,7 +7104,8 @@ a.setAttribute('href', 'http://example.com/'); // change the content attribute d
<dt><var>collection</var> = <var>collection</var> . <code data-x="dom-HTMLAllCollection-namedItem">namedItem</code>(<var>name</var>)</dt>
<dt><var>element</var> = <var>collection</var>(<var>name</var>)</dt>
<dt><var>collection</var> = <var>collection</var>(<var>name</var>)</dt>
<dt><var>collection</var>[<var>name</var>]</dt>
<dt><var>element</var> = <var>collection</var>[<var>name</var>]</dt>
<dt><var>collection</var> = <var>collection</var>[<var>name</var>]</dt>
<dd>
<p>Returns the item with <span data-x="concept-id">ID</span> or name <var>name</var> from the collection.</p>
<p>If there are multiple matching items, then an <code>HTMLCollection</code> object containing all those elements is returned.</p>
Expand All @@ -7121,10 +7123,6 @@ a.setAttribute('href', 'http://example.com/'); // change the content attribute d
<p>The object's <span>supported property indices</span> are as defined for
<code>HTMLCollection</code> objects.</p>

<p>The <dfn><code data-x="dom-HTMLAllCollection-item">item()</code></dfn> method, when invoked
with a numeric argument, must act like the <span data-x="dom-HTMLCollection-item">item()</span>
method inherited from <code>HTMLCollection</code>.</p>

<!-- http://software.hixie.ch/utilities/js/live-dom-viewer/?saved=2837 -->
<p>The following elements are <dfn>"all"-named elements</dfn>:
<code>a</code>, <!-- in some browsers -->
Expand Down Expand Up @@ -7155,6 +7153,14 @@ a.setAttribute('href', 'http://example.com/'); // change the content attribute d

<p>The properties exposed in this way must be <span>unenumerable</span>.</p>

<p>On getting, the <dfn><code data-x="dom-HTMLAllCollection-length">length</code></dfn>
attribute must return the number of nodes <span>represented by the collection</span>.</p>

<p>The <dfn><code data-x="dom-HTMLAllCollection-item">item(<var>index</var>)</code></dfn> method
must return the <var>index</var><sup>th</sup> element in the collection. If there is no
<var>index</var><sup>th</sup> element in the <span data-x="concept-collection">collection</span>,
then the method must return null.</p>

<p>The <dfn><code data-x="dom-HTMLAllCollection-item-string">item(<var>name</var>)</code></dfn> and <dfn><code data-x="dom-HTMLAllCollection-namedItem">namedItem(<var>name</var>)</code></dfn>
methods must act according to the following algorithm:</p>

Expand Down Expand Up @@ -7193,9 +7199,9 @@ a.setAttribute('href', 'http://example.com/'); // change the content attribute d

<h5>The <code>HTMLFormControlsCollection</code> interface</h5>

<p>The <code>HTMLFormControlsCollection</code> interface is used for <span>collections</span> of
<span data-x="category-listed">listed elements</span> in <code>form</code> and
<code>fieldset</code> elements.</p>
<p>The <code>HTMLFormControlsCollection</code> interface is used for
<span data-x="concept-collection">collections</span> of <span data-x="category-listed">listed
elements</span> in <code>form</code> and <code>fieldset</code> elements.</p>

<pre class="idl">interface <dfn>HTMLFormControlsCollection</dfn> : <span>HTMLCollection</span> {
// inherits <span data-x="dom-HTMLCollection-length">length</span> and <span data-x="dom-HTMLCollection-item">item</span>()
Expand All @@ -7214,7 +7220,7 @@ interface <dfn>RadioNodeList</dfn> : <span>NodeList</span> {
</dd>

<dt><var>element</var> = <var>collection</var> . <code data-x="dom-HTMLCollection-item">item</code>(<var>index</var>)</dt>
<dt><var>collection</var>[<var>index</var>]</dt>
<dt><var>element</var> = <var>collection</var>[<var>index</var>]</dt>
<dd>
<p>Returns the item with index <var>index</var> from the collection. The items are sorted in <span>tree order</span>.</p>
</dd>
Expand Down Expand Up @@ -7334,9 +7340,10 @@ http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20html%3E..

<h5>The <code>HTMLOptionsCollection</code> interface</h5>

<p>The <code>HTMLOptionsCollection</code> interface is used for <span>collections</span> of
<code>option</code> elements. It is always rooted on a <code>select</code> element and has
attributes and methods that manipulate that element's descendants.</p>
<p>The <code>HTMLOptionsCollection</code> interface is used for <span
data-x="concept-collection">collections</span> of <code>option</code> elements. It is always
rooted on a <code>select</code> element and has attributes and methods that manipulate that
element's descendants.</p>

<pre class="idl">interface <dfn>HTMLOptionsCollection</dfn> : <span>HTMLCollection</span> {
// inherits <span data-x="dom-HTMLCollection-item">item</span>(), <span data-x="dom-HTMLCollection-namedItem">namedItem</span>()
Expand All @@ -7357,7 +7364,7 @@ http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20html%3E..
</dd>

<dt><var>element</var> = <var>collection</var> . <code data-x="dom-HTMLCollection-item">item</code>(<var>index</var>)</dt>
<dt><var>collection</var>[<var>index</var>]</dt>
<dt><var>element</var> = <var>collection</var>[<var>index</var>]</dt>
<dd>
<p>Returns the item with index <var>index</var> from the collection. The items are sorted in <span>tree order</span>.</p>
</dd>
Expand Down

0 comments on commit 4bade08

Please sign in to comment.