[whatwg] getElementsByClassName

Lachlan Hunt wrote:
> 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 

I agree with Simon here. Allowing arrays to be passed in doesn't add any 
extra value and complicates the implementation significantly. I think 
that the by far most common case is going to be passing a single class 
name, so adding multiple ways of passing multiple class names seems like 
overkill.

/ Jonas

Received on Monday, 9 July 2007 19:55:53 UTC