HTML Standard Tracker

Diff (omit for latest revision)
Filter

Short URL: http://html5.org/r/3409

File a bug

SVNBugCommentTime (UTC)
3409Define HTMLAllCollection for document.all. (Should we give it the [[Class]] HTMLCollection?)2009-07-14 07:21
Index: source
===================================================================
--- source	(revision 3408)
+++ source	(revision 3409)
@@ -4950,7 +4950,7 @@
 
   <h4>Collections</h4>
 
-  <p>The <code>HTMLCollection</code>,
+  <p>The <code>HTMLCollection</code>, <code>HTMLAllCollection</code>,
   <code>HTMLFormControlsCollection</code>,
   <code>HTMLOptionsCollection</code>, and
   <code>HTMLPropertyCollection</code> interfaces represent various
@@ -5002,7 +5002,7 @@
   readonly attribute unsigned long <span title="dom-HTMLCollection-length">length</span>;
   [IndexGetter] Element <span title="dom-HTMLCollection-item">item</span>(in unsigned long index);
   [NameGetter] Element <span title="dom-HTMLCollection-namedItem">namedItem</span>(in DOMString name);
-  <span>HTMLCollection</span> <span title="dom-HTMLCollection-tags">tags</span>(in DOMString tagName);
+  <span>HTMLAllCollection</span> <span title="dom-HTMLCollection-tags">tags</span>(in DOMString tagName);
 };</pre>
 
   <dl class="domintro">
@@ -5020,7 +5020,6 @@
    </dd>
 
    <dt><var title="">element</var> = <var title="">collection</var> . <code title="dom-HTMLCollection-item">namedItem</code>(<var title="">name</var>)</dt>
-   <dt><var title="">nodeList</var> = <var title="">collection</var> . <code title="dom-HTMLCollection-item">namedItem</code>(<var title="">name</var>)</dt>
    <dt><var title="">collection</var>[<var title="">name</var>]</dt>
    <dt><var title="">collection</var>(<var title="">name</var>)</dt>
    <dd>
@@ -5096,10 +5095,153 @@
 
   <p>The <dfn title="dom-HTMLCollection-tags"><code>tags(<var
   title="">tagName</var>)</code></dfn> method must return an
-  <code>HTMLCollection</code> rooted at the same node as the
+  <code>HTMLAllCollection</code> rooted at the same node as the
   <code>HTMLCollection</code> object on which the method was invoked,
   whose filter matches only <span>HTML elements</span> whose local
-  name is the <var title="">tagName</var> argument. In <span>HTML
+  name is the <var title="">tagName</var> argument and that already
+  match the filter of the <code>HTMLCollection</code> object on which
+  the method was invoked. In <span>HTML documents</span>, the argument
+  must first be <span>converted to ASCII lowercase</span>.</p>
+
+  </div>
+
+
+  <h5>HTMLAllCollection</h5>
+
+  <p>The <code>HTMLAllCollection</code> interface represents a generic
+  <span title="collections">collection</span> of elements just like
+  <code>HTMLCollection</code>, with the exception that its <code
+  title="dom-HTMLAllCollection-namedItem">namedItem()</code> method
+  returns an <code>HTMLCollection</code> object when there are
+  multiple matching elements.</p>
+
+  <!-- see notes in previous section -->
+  <pre class="idl">[Callable=<span title="dom-HTMLAllCollection-namedItem">namedItem</span>]
+interface <dfn>HTMLAllCollection</dfn> {
+  readonly attribute unsigned long <span title="dom-HTMLAllCollection-length">length</span>;
+  [IndexGetter] Element <span title="dom-HTMLAllCollection-item">item</span>(in unsigned long index);
+  [NameGetter] Object <span title="dom-HTMLAllCollection-namedItem">namedItem</span>(in DOMString name);
+  <span>HTMLAllCollection</span> <span title="dom-HTMLAllCollection-tags">tags</span>(in DOMString tagName);
+};</pre>
+
+  <dl class="domintro">
+
+   <dt><var title="">collection</var> . <code title="dom-HTMLAllCollection-length">length</code></dt>
+   <dd>
+    <p>Returns the number of elements in the collection.</p>
+   </dd>
+
+   <dt><var title="">element</var> = <var title="">collection</var> . <code title="dom-HTMLAllCollection-item">item</code>(<var title="">index</var>)</dt>
+   <dt><var title="">collection</var>[<var title="">index</var>]</dt>
+   <dd>
+    <p>Returns the item with index <var title="">index</var> from the collection. The items are sorted in <span>tree order</span>.</p>
+    <p>Returns null if <var title="">index</var> is out of range.</p>
+   </dd>
+
+   <dt><var title="">element</var> = <var title="">collection</var> . <code title="dom-HTMLAllCollection-item">namedItem</code>(<var title="">name</var>)</dt>
+   <dt><var title="">collection</var> = <var title="">collection</var> . <code title="dom-HTMLAllCollection-item">namedItem</code>(<var title="">name</var>)</dt>
+   <dt><var title="">collection</var>[<var title="">name</var>]</dt>
+   <dt><var title="">collection</var>(<var title="">name</var>)</dt>
+   <dd>
+    <p>Returns the item with ID or name <var title="">name</var> from the collection.</p>
+    <p>If there are multiple matching items, then an <code>HTMLAllCollection</code> object containing all those elements is returned.</p>
+    <p>Returns null if no element with that ID or name could be found.</p>
+    <p>Only <code>a</code>, <code>applet</code>, <code>area</code>,
+    <code>embed</code>, <code>form</code>, <code>frame</code>,
+    <code>frameset</code>, <code>iframe</code>, <code>img</code>, and
+    <code>object</code> elements can have a name for the purpose of
+    this method; their name is given by the value of their <code
+    title="">name</code> attribute.</p>
+   </dd>
+
+   <dt><var title="">collection</var> = <var title="">collection</var> . <code title="dom-HTMLAllCollection-tags">tags</code>(<var title="">tagName</var>)</dt>
+   <dd>
+    <p>Returns a collection that is a filtered view of the current collection, containing only elements with the given tag name.</p>
+   </dd>
+
+  </dl>
+
+  <div class="impl">
+
+  <hr>
+
+  <p>The object's <span>indices of the supported indexed
+  properties</span> are the numbers in the range zero to one less than
+  the number of nodes <span>represented by the collection</span>. If
+  there are no such elements, then there are no <span>supported
+  indexed properties</span>.</p>
+
+  <p>The <dfn
+  title="dom-HTMLAllCollection-length"><code>length</code></dfn>
+  attribute must return the number of nodes <span>represented by the
+  collection</span>.</p>
+
+  <p>The <dfn title="dom-HTMLAllCollection-item"><code>item(<var
+  title="">index</var>)</code></dfn> method must return the <var
+  title="">index</var>th node in the collection. If there is no <var
+  title="">index</var>th node in the collection, then the method must
+  return null.</p>
+
+  <p>The <span>names of the supported named properties</span> consist
+  of the values of the <code title="">name</code> attributes of each
+  <code>a</code>, <code>applet</code>, <code>area</code>,
+  <code>embed</code>, <code>form</code>, <code>frame</code>,
+  <code>frameset</code>, <code>iframe</code>, <code>img</code>, and
+  <code>object</code> element <span>represented by the
+  collection</span> with a <code title="">name</code> attribute, plus
+  the list of IDs that the elements <span>represented by the
+  collection</span> have.</p>
+
+  <p>The <dfn
+  title="dom-HTMLAllCollection-namedItem"><code>namedItem(<var
+  title="">key</var>)</code></dfn> method must act according to the
+  following algorithm:</p>
+
+  <ol>
+
+   <li>
+
+    <p>Let <var title="">collection</var> be an
+    <code>HTMLAllCollection</code> object rooted at the same node as
+    the <code>HTMLAllCollection</code> object on which the method was
+    invoked, whose filter matches only only elements that already
+    match the filter of the <code>HTMLAllCollection</code> object on
+    which the method was invoked and that are either:</p>
+
+    <ul>
+
+     <li><code>a</code>, <code>applet</code>, <code>area</code>,
+     <code>embed</code>, <code>form</code>, <code>frame</code>,
+     <code>frameset</code>, <code>iframe</code>, <code>img</code>, or
+     <code>object</code> elements with a <code title="">name</code>
+     attribute equal to <var title="">key</var>, or,</li>
+
+     <li>elements with an ID <var title="">key</var>.</li>
+
+    </ul>
+
+   </li>
+
+   <li>If, at the time the method is called, there is exactly one node
+   in <var title="">collection</var>, then return that node and stop
+   the algorithm.</li>
+
+   <li>Otherwise, if, at the time the method is called, <var
+   title="">collection</var> is empty, return null and stop the
+   algorithm.</li>
+
+   <li>Otherwise, return <var title="">collection</var>.</li>
+
+  </ol>
+
+  <p>The <dfn title="dom-HTMLAllCollection-tags"><code>tags(<var
+  title="">tagName</var>)</code></dfn> method must return an
+  <code>HTMLAllCollection</code> rooted at the same node as the
+  <code>HTMLAllCollection</code> object on which the method was
+  invoked, whose filter matches only <span>HTML elements</span> whose
+  local name is the <var title="">tagName</var> argument and that
+  already match the filter of the <code>HTMLAllCollection</code>
+  object on which the method was invoked. In <span>HTML
   documents</span>, the argument must first be <span>converted to
   ASCII lowercase</span>.</p>
 

|