[whatwg] [WA1] getElementsByClass

I'm very happy to see the getElementsByClass() method introduced in WA1,
that is definitely something missing from current DOM specs. However,
there seems to be no way defined for selecting elements with multiple
class names.

Let's say we have the following elements:

<div class="green" />
<div class="green car" />
<div class="car green" />
<div class="car green british" />

If I use getElementsByClass('green') I would select all four of the
elements. If I use getElementsByClass('car') then I would select the last
three.

What happens if I want to select all elements with class="car green" (and
that selection should include the equivalent class="green car")? That is
currently undefined. And let's assume that this was implemented and if I
were to search for getElementsByClass("car green") would it also select
the fourth one? Or should it only select completely matching classes?

So in other words, in what way would getElementsByClass() be equivalent to
the CSS3 Selectors[1]? Would it be equivalent to:

E[class~="bar"]
(and in the case of multiple classes we switch to E.bar.foo which is
equivalent to E.foo.bar)

or to:
E[class="bar"]

I think that in practice the first option would be the most useful.

-- 
Mark Schenk

Received on Thursday, 26 August 2004 07:17:13 UTC