W3C home > Mailing lists > Public > whatwg@whatwg.org > November 2006

[whatwg] getElementsByClassName() idea

From: Lachlan Hunt <lachlan.hunt@lachy.id.au>
Date: Sun, 05 Nov 2006 21:54:06 +1100
Message-ID: <454DC2CE.5070302@lachy.id.au>
Anne van Kesteren wrote:
> I think this hasn't been suggested before. Perhaps the method should 
> accept a DOMTokenString as argument instead of an array. This allows 
> things like ele.getElementsByClassName(ele.className) etc.

Since a DOMTokenString just extends DOMString, anything that accepts a 
DOMString will automatically be able to accept a DOMTokenString, 
including getElementsByClassName.  So your example will already work. 
Conversely, if it were defined as accepting a DOMTokenString, you 
couldn't pass it a regular string.

> The only problem is how to get a DOMTokenString without first getting 
> className from somewhere. Perhaps it should be a constructor as well. 
> 'x = new DOMTokenString("aaa bbb")'

That might be useful.  Though, I can't think of any specific use cases 
for needing it other than for class names.

Lachlan Hunt
Received on Sunday, 5 November 2006 02:54:06 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:58:49 UTC