[html5] r1038 - /

whatwg at whatwg.org whatwg at whatwg.org
Mon Oct 8 14:26:25 PDT 2007


Author: ianh
Date: 2007-10-08 14:26:21 -0700 (Mon, 08 Oct 2007)
New Revision: 1038

Modified:
   index
   source
Log:
[g] (2) Fix getElementsByClassName() to take a string instead of an array.

Modified: index
===================================================================
--- index	2007-10-08 19:28:51 UTC (rev 1037)
+++ index	2007-10-08 21:26:21 UTC (rev 1038)
@@ -2525,7 +2525,7 @@
   readonly attribute <a href="#htmlcollection0">HTMLCollection</a> <a href="#forms0" title=dom-document-forms>forms</a>;
   readonly attribute <a href="#htmlcollection0">HTMLCollection</a> <a href="#anchors" title=dom-document-anchors>anchors</a>;
   NodeList <a href="#getelementsbyname" title=dom-document-getElementsByName>getElementsByName</a>(in DOMString elementName);
-  NodeList <a href="#getelementsbyclassname" title=dom-document-getElementsByClassName>getElementsByClassName</a>(in DOMString[] classNames);
+  NodeList <a href="#getelementsbyclassname" title=dom-document-getElementsByClassName>getElementsByClassName</a>(in DOMString classNames);
 
   // <a href="#dynamic2">Dynamic markup insertion</a>
            attribute DOMString <a href="#innerhtml" title=dom-innerHTML>innerHTML</a>;
@@ -2730,7 +2730,7 @@
   <pre
    class=idl>interface <dfn id=htmlelement>HTMLElement</dfn> : <span>Element</span> {
   // <a href="#dom-tree0">DOM tree accessors</a>
-  NodeList <a href="#getelementsbyclassname0" title=dom-getElementsByClassName>getElementsByClassName</a>(in DOMString[] classNames);
+  NodeList <a href="#getelementsbyclassname0" title=dom-getElementsByClassName>getElementsByClassName</a>(in DOMString classNames);
 
   // <a href="#dynamic2">dynamic markup insertion</a>
            attribute DOMString <a href="#innerhtml" title=dom-innerHTML>innerHTML</a>;
@@ -3204,8 +3204,8 @@
   readonly attribute unsigned long <a href="#length2" title=dom-tokenlist-length>length</a>;
   DOMString <a href="#itemindex2" title=dom-tokenlist-item>item</a>(in unsigned long index);
   boolean <a href="#hastoken" title=dom-tokenlist-has>has</a>(in DOMString token);
-  void <a href="#remove" title=dom-tokenlist-add>add</a>(in DOMString token);
-  void <span title=dom-tokenlist-remove>remove</span>(in DOMString token);
+  void <a href="#addtoken" title=dom-tokenlist-add>add</a>(in DOMString token);
+  void <a href="#remove" title=dom-tokenlist-remove>remove</a>(in DOMString token);
   boolean <a href="#toggle" title=dom-tokenlist-toggle>toggle</a>(in DOMString token);
 };</pre>
 
@@ -3279,7 +3279,7 @@
     underlying string.
   </ol>
 
-  <p>The <dfn id=remove title=dom-tokenlist-add><code>remove(<var
+  <p>The <dfn id=remove title=dom-tokenlist-remove><code>remove(<var
    title="">token</var>)</code></dfn> method must run the following
    algorithm:
 
@@ -3524,24 +3524,37 @@
 
   <p>The <dfn id=getelementsbyclassname
    title=dom-document-getElementsByClassName><code>getElementsByClassName(<var
-   title="">classNames</var>)</code></dfn> method takes an array of strings
-   representing classes. When called, the method must return a live
-   <code>NodeList</code> object containing all the elements in the document
-   that have all the classes specified in that array. If the array is empty,
-   then the method must return an empty <code>NodeList</code>.
+   title="">classNames</var>)</code></dfn> method takes a string that
+   contains an <a href="#unordered">unordered set of space-separated
+   tokens</a> representing classes. When called, the method must return a
+   live <code>NodeList</code> object containing all the elements in the
+   document that have all the classes specified in that argument, having
+   obtained the classes by <a href="#split" title="split a string on
+   spaces">splitting a string on spaces</a>. If there are no tokens specified
+   in the argument, then the method must return an empty
+   <code>NodeList</code>.
 
-  <p class=big-issue>getElementsByClassName() will probably be changed to
-   take a space-separated list of tokens as a single string, not an array.
+  <p>The <dfn id=getelementsbyclassname0
+   title=dom-getElementsByClassName><code>getElementsByClassName()</code></dfn>
+   method on the <code><a href="#htmlelement">HTMLElement</a></code>
+   interface must return a live <code>NodeList</code> with the nodes that the
+   <code><a href="#htmldocument">HTMLDocument</a></code> <code
+   title=dom-document-getElementsByClassName><a
+   href="#getelementsbyclassname">getElementsByClassName()</a></code> method
+   would return when passed the same argument(s), excluding any elements that
+   are not descendants of the <code><a
+   href="#htmlelement">HTMLElement</a></code> object on which the method was
+   invoked.
 
-  <p>HTML, XHTML, SVG and MathML elements define which classes they are in by
+  <p>HTML, SVG, and MathML elements define which classes they are in by
    having an attribute in the per-element partition with the name <code
    title="">class</code> containing a space-separated list of classes to
    which the element belongs. Other specifications may also allow elements in
    their namespaces to be labelled as being in specific classes. UAs must not
-   assume that all attributes of the name <code>class</code> for elements in
-   any namespace work in this way, however, and must not assume that such
-   attributes, when used as global attributes, label other elements as being
-   in specific classes.
+   assume that all attributes of the name <code title="">class</code> for
+   elements in any namespace work in this way, however, and must not assume
+   that such attributes, when used as global attributes, label other elements
+   as being in specific classes.
 
   <div class=example>
    <p>Given the following XHTML fragment:</p>
@@ -3557,29 +3570,14 @@
     would return a <code>NodeList</code> with the two paragraphs
     <code>p1</code> and <code>p2</code> in it.</p>
 
-   <p>A call to <code>getElementsByClassName(['ccc', 'bbb'])</code> would
+   <p>A call to <code>getElementsByClassName('ccc bbb')</code> would
     only return one node, however, namely <code>p3</code>. A call to
-    <code>document.getElementById('example').getElementsByClassName('ccc
-    bbb')</code> would return the same thing.</p>
+    <code>document.getElementById('example').getElementsByClassName('bbb  ccc ')</code>
+    would return the same thing.</p>
 
-   <p>A call to <code>getElementsByClassName(['aaa bbb'])</code> would return
-    no nodes; none of the elements above are in the "aaa bbb" class.</p>
-
-   <p>A call to <code>getElementsByClassName([''])</code> would also return
-    no nodes, since none of the nodes are in the "" class (indeed, in HTML,
-    it is impossible to specify that an element is in the "" class).</p>
+   <p>A call to <code>getElementsByClassName('aaa,bbb')</code> would return
+    no nodes; none of the elements above are in the "aaa,bbb" class.</p>
   </div>
-
-  <p>The <dfn id=getelementsbyclassname0
-   title=dom-getElementsByClassName><code>getElementsByClassName()</code></dfn>
-   method on the <code><a href="#htmlelement">HTMLElement</a></code>
-   interface must return the nodes that the <code><a
-   href="#htmldocument">HTMLDocument</a></code> <code
-   title=dom-document-getElementsByClassName><a
-   href="#getelementsbyclassname">getElementsByClassName()</a></code> method
-   would return, excluding any elements that are not descendants of the
-   <code><a href="#htmlelement">HTMLElement</a></code> object on which the
-   method was invoked.</p>
   <!-- XXX
 >         * xGetParentElementByClassName(rootElement, className, tagName) -
 > Navigates upwards until we hit a parent element with the given class name and

Modified: source
===================================================================
--- source	2007-10-08 19:28:51 UTC (rev 1037)
+++ source	2007-10-08 21:26:21 UTC (rev 1038)
@@ -940,7 +940,7 @@
   readonly attribute <span>HTMLCollection</span> <span title="dom-document-forms">forms</span>;
   readonly attribute <span>HTMLCollection</span> <span title="dom-document-anchors">anchors</span>;
   NodeList <span title="dom-document-getElementsByName">getElementsByName</span>(in DOMString elementName);
-  NodeList <span title="dom-document-getElementsByClassName">getElementsByClassName</span>(in DOMString[] classNames);
+  NodeList <span title="dom-document-getElementsByClassName">getElementsByClassName</span>(in DOMString classNames);
 
   // <span>Dynamic markup insertion</span>
            attribute DOMString <span title="dom-innerHTML">innerHTML</span>;
@@ -1159,7 +1159,7 @@
 
   <pre class="idl">interface <dfn>HTMLElement</dfn> : <span>Element</span> {
   // <span>DOM tree accessors</span>
-  NodeList <span title="dom-getElementsByClassName">getElementsByClassName</span>(in DOMString[] classNames);
+  NodeList <span title="dom-getElementsByClassName">getElementsByClassName</span>(in DOMString classNames);
 
   // <span>dynamic markup insertion</span>
            attribute DOMString <span title="dom-innerHTML">innerHTML</span>;
@@ -1724,7 +1724,7 @@
 
   </ol>
 
-  <p>The <dfn title="dom-tokenlist-add"><code>remove(<var
+  <p>The <dfn title="dom-tokenlist-remove"><code>remove(<var
   title="">token</var>)</code></dfn> method must run the following
   algorithm:</p>
 
@@ -1973,62 +1973,64 @@
 
   <p>The <dfn
   title="dom-document-getElementsByClassName"><code>getElementsByClassName(<var
-  title="">classNames</var>)</code></dfn> method takes an array of
-  strings representing classes. When called, the method must return a
-  live <code>NodeList</code> object containing all the elements in the
-  document that have all the classes specified in that array. If the
-  array is empty, then the method must return an empty
+  title="">classNames</var>)</code></dfn> method takes a string that
+  contains an <span>unordered set of space-separated tokens</span>
+  representing classes. When called, the method must return a live
+  <code>NodeList</code> object containing all the elements in the
+  document that have all the classes specified in that argument,
+  having obtained the classes by <span title="split a string on
+  spaces">splitting a string on spaces</span>. If there are no tokens
+  specified in the argument, then the method must return an empty
   <code>NodeList</code>.</p>
 
-  <p class="big-issue">getElementsByClassName() will probably be
-  changed to take a space-separated list of tokens as a single string,
-  not an array.</p>
+  <p>The <dfn
+  title="dom-getElementsByClassName"><code>getElementsByClassName()</code></dfn>
+  method on the <code>HTMLElement</code> interface must return a live
+  <code>NodeList</code> with the nodes that the
+  <code>HTMLDocument</code> <code
+  title="dom-document-getElementsByClassName">getElementsByClassName()</code>
+  method would return when passed the same argument(s), excluding any
+  elements that are not descendants of the <code>HTMLElement</code>
+  object on which the method was invoked.</p>
 
-  <p>HTML, XHTML, SVG and MathML elements define which classes they
-  are in by having an attribute in the per-element partition with the
-  name <code title="">class</code> containing a space-separated list
-  of classes to which the element belongs. Other specifications may
-  also allow elements in their namespaces to be labelled as being in
+  <p>HTML, SVG, and MathML elements define which classes they are in
+  by having an attribute in the per-element partition with the name
+  <code title="">class</code> containing a space-separated list of
+  classes to which the element belongs. Other specifications may also
+  allow elements in their namespaces to be labelled as being in
   specific classes. UAs must not assume that all attributes of the
-  name <code>class</code> for elements in any namespace work in this
-  way, however, and must not assume that such attributes, when used as
-  global attributes, label other elements as being in specific
+  name <code title="">class</code> for elements in any namespace work
+  in this way, however, and must not assume that such attributes, when
+  used as global attributes, label other elements as being in specific
   classes.</p>
 
   <div class="example">
+
    <p>Given the following XHTML fragment:</p>
+
    <pre><div id="example">
  <p id="p1" class="aaa bbb"/>
  <p id="p2" class="aaa ccc"/>
  <p id="p3" class="bbb ccc"/>
 </div></pre>
+
    <p>A call to
    <code>document.getElementById('example').getElementsByClassName('aaa')</code>
    would return a <code>NodeList</code> with the two paragraphs
    <code>p1</code> and <code>p2</code> in it.</p>
-   <p>A call to <code>getElementsByClassName(['ccc', 'bbb'])</code>
-   would only return one node, however, namely <code>p3</code>.  A
-   call to
-   <code>document.getElementById('example').getElementsByClassName('ccc
-   bbb')</code> would return the same thing.</p>
-   <p>A call to <code>getElementsByClassName(['aaa bbb'])</code> would
-   return no nodes; none of the elements above are in the "aaa bbb"
+
+   <p>A call to <code>getElementsByClassName('ccc bbb')</code>
+   would only return one node, however, namely <code>p3</code>. A call
+   to
+   <code>document.getElementById('example').getElementsByClassName('bbb  ccc ')</code>
+   would return the same thing.</p>
+
+   <p>A call to <code>getElementsByClassName('aaa,bbb')</code> would
+   return no nodes; none of the elements above are in the "aaa,bbb"
    class.</p>
-   <p>A call to <code>getElementsByClassName([''])</code> would also
-   return no nodes, since none of the nodes are in the "" class
-   (indeed, in HTML, it is impossible to specify that an element is in
-   the "" class).</p>
+
   </div>
 
-  <p>The <dfn
-  title="dom-getElementsByClassName"><code>getElementsByClassName()</code></dfn>
-  method on the <code>HTMLElement</code> interface must return the
-  nodes that the <code>HTMLDocument</code> <code
-  title="dom-document-getElementsByClassName">getElementsByClassName()</code>
-  method would return, excluding any elements that are not descendants
-  of the <code>HTMLElement</code> object on which the method was
-  invoked.</p>
-
 <!-- XXX
 >         * xGetParentElementByClassName(rootElement, className, tagName) -
 > Navigates upwards until we hit a parent element with the given class name and




More information about the Commit-Watchers mailing list