[whatwg] getElementsByClassName()

Aankhen aankhen at gmail.com
Sun Sep 4 22:27:30 PDT 2005

On 9/5/05, Lachlan Hunt <lachlan.hunt at lachy.id.au> wrote:
> 1. Equivalent to ("foo", "bar") (or [class~=foo][class~=bar], or
>     .foo.bar in CSS)
> 2. The way it currently works. ie. matches "foo bar", not "bar foo"
> 3. Error, return nothing.

I suggest #2, which implies consistently treating the first argument
passed to the function as a single class name to match (this means
"foo bar" would always return no elements, since a class name
obviously cannot contain whitespace).  Special-casing "foo bar" and
other values seems to be adding complexity without much return.

If multiple class names really need to be handled, my suggestion would
be to take a single array as a parameter, e.g.
`getElementsByClassName(["foo"])` and `getElementsByClassName(["foo",


More information about the whatwg mailing list