[whatwg] getElementsByClassName()
ROBO Design
robodesign at gmail.com
Fri Feb 3 02:25:01 PST 2006
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
More information about the whatwg
mailing list