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

[whatwg] getElementsByClassName()

From: Gervase Markham <gerv@mozilla.org>
Date: Fri, 03 Feb 2006 13:39:26 +0000
Message-ID: <43E35D0E.6080500@mozilla.org>
ROBO Design wrote:
> I believe there's some disagreement on what is this function supposed to
> do.

Well, not according to the current spec, which says:

> 1. Should it return *all* elements which have *all* the class names wanted?

this one. Of course, you may disagree with the spec.

> 4. Should the order matter?

No, because class name ordering does not matter in the source or in CSS.

> I also believe this function will always be confusing, no matter what.
> To drop all confusion just rename it to getElementsByCSSselector() and
> you get the exact idea to as what you are supposed to provide as an
> argument (if you know CSS). Yet, this is something Ian Hickson said is
> beyond the purpose of WHATWG.

That turns the function into something which is dependent on CSS rather
than just dependent on the markup language. That is a reasonably large
change in scope IMO.

CSS selector parsers in JS have been written (I believe Dean Edwards has
one); but such things would be much easier to implement if you had
getElementsByClassNames() to go with getElementsById().

Gerv
Received on Friday, 3 February 2006 05:39:26 UTC

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