[whatwg] getElementsByClassName()

Kornel Lesinski kornel at ideadesigners.com
Sun Sep 4 10:55:49 PDT 2005

On Sun, 04 Sep 2005 17:51:43 +0100, Anne van Kesteren  
<fora at annevankesteren.nl> wrote:

>> It will also solve IMHO unclear case of getElementsByClassName("foo  
>> bar")  matching "bar foo". It would, as opposed to behavior where space  
>> is both  separator and part of class name.
> This is not how the CLASS attribute works. "foo bar" means the element  
> has two classes bound to it, "foo" and "bar". With your syntax,
> getElementsByClassName("bar foo") would also need to match an element  
> with "foo bar" as value for the CLASS attribute.

Sorry, that sentence might have been unclear.

In currently proposed implementation getElementsByClassName("foo bar")  
doesn't match class="bar foo", but matches class="foo bar". This implies  
that class attribute isn't just space-separated list of classes.

That's why I propose to make this function use exactly the syntax that  
class attribute uses.
getElementsByClassName("bar foo") should match class="foo bar", class="bar  
baz foo", etc.

regards, Kornel Lesinski

More information about the whatwg mailing list