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 committed Sep 30, 2015
1 parent 3768403 commit 1009d38
Showing 1 changed file with 27 additions and 20 deletions.
47 changes: 27 additions & 20 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-x="dom-collection" data-noexport="">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="dom-collection">collections</span> derived from the <code>HTMLCollection</code>
interface. The <code>HTMLAllCollection</code> interface is a <span
data-x="dom-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,9 +7123,13 @@ 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>On getting, the <dfn><code data-x="dom-HTMLAllCollection-length">length</code></dfn>
attribute must act like the <span data-x="dom-HTMLCollection-length">length</span> attribute of
<code>HTMLCollection</code>.</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>
method of <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>:
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="dom-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="dom-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 1009d38

Please sign in to comment.