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

[whatwg] getElementsByClassName()

From: Gervase Markham <gerv@mozilla.org>
Date: Fri, 03 Feb 2006 08:48:47 +0000
Message-ID: <43E318EF.8010701@mozilla.org>
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

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