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

[whatwg] getElementsByClassName

From: Simon Pieters <zcorpan@gmail.com>
Date: Fri, 06 Jul 2007 16:07:29 +0200
Message-ID: <op.tu1qurau7a8kvn@hp-a0a83fcd39d2>
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?

Firefox has implemented it as a space separated string as argument. This  
seems more practical for the simple case and you can still pass an  
element's .className as argument (if DOMTokenList.toString is defined to  
return a string with the tokens being space separated, .classList can be  
passed as argument too). I don't think that the argument of being able to  
use classes containing spaces is relevant since no Web technology I know  
of can have classes containing spaces. I think that the argument of  
authors not understanding that the order doesn't matter applies equally  
much to CSS .foo.bar vs .bar.foo. For these reasons, I think the spec  
should use space separated string as argument instead of array (and  
perhaps define DOMTokenList.toString to be useful).


Finally, an editorial comment, the example uses both string as argument  
and array as argument. This might be confusing unless both are accepted.

-- 
Simon Pieters
Received on Friday, 6 July 2007 07:07:29 UTC

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