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

[whatwg] getElementsByClassName()

From: ROBO Design <robodesign@gmail.com>
Date: Fri, 03 Feb 2006 12:25:01 +0200
Message-ID: <op.s4d67zq6mapogm@localhost.localdomain>
On Fri, 03 Feb 2006 10:48:47 +0200, Gervase Markham <gerv at mozilla.org>  
wrote:

> Brad Fults wrote:
<...>
>
> 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

Hello!
I wouldn't go for:
getElementsByClassName("foo", "bar")

Because that's not ideal in my opinion, since that makes harder to add an  
arbitrary number of classes to search for programatically.

I would go for:
getElementsByClassName("foo bar")

But, as you said, that can add some confusion. Therefore, this is ideal:
getElementsByClassName(["foo", "bar"])


-- 
http://www.robodesign.ro
ROBO Design - We bring you the future
Received on Friday, 3 February 2006 02:25:01 UTC

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