W3C home > Mailing lists > Public > whatwg@whatwg.org > July 2007

[whatwg] getElementsByClassName

From: Lachlan Hunt <lachlan.hunt@lachy.id.au>
Date: Sat, 07 Jul 2007 00:37:34 +1000
Message-ID: <468E53AE.70505@lachy.id.au>
Simon Pieters wrote:
> getElementsByClassName is defined to take an array of strings as 
> argument. What exactly is an array? A native ECMAScript array, or 
> anything with a 'length' property and the properties '0' -> length-1? Is 
> a DOMTokenList an "array" that can be passed to gEBCN?

It could be defined to accept either a space separated string or an 
array.  Using the [Overloads] extended attributed defined in the 
Language Bindings for DOM Specifications draft [1], it could be defined 
like this:

NodeList getElementsByClassName(in DOMString classNames);
[Overloads=getElementsByClassName]
      NodeList getElementsByClassNameArray(in DOMString[] classNames);

For ECMAScript, that effectively means that getElementsByClassName() can 
be called with either a space separated string of class names or an array.

[1] 
http://dev.w3.org/cvsweb/~checkout~/2006/webapi/Binding4DOM/Overview.html?content-type=text/html;%20charset=utf-8#Overloads

-- 
Lachlan Hunt
http://lachy.id.au/
Received on Friday, 6 July 2007 07:37:34 UTC

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:08:36 UTC