[whatwg] getElementsByClassName()

Brad Fults wrote:
> I see this is still an open issue[1]. Is this now implemented as #1
> (space-delimited class names to match)?
> 
> I suggest either going with the space-delimited approach (as it's
> language-agnostic and well-defined at least) or with Aankhen's
> suggestion of a single array argument.

Musing...

If you have:

<p class="foo bar">Fred</p>
<p class="bar foo">Barney</p>
<p class="foo baz bar">Wilma</p>

which should be picked up by getElementsByClassName("foo bar")?

In the "string split" mode, it would pick up all three. However, I
suggest that designers might be misled by this interface into thinking
that it only picks up the first one - which matches exactly.

So I think a multiple-argument interface would remove this possible
confusion, and make things more obvious than a whitespace-splitting
interface.

getElementsByClassName("foo", "bar") ideally, but if that's hard, then
getElementsByClassName(["foo", "bar"]);

So I agree with Brad, I think :-)

Gerv

Received on Friday, 3 February 2006 00:48:47 UTC