lachlan.hunt at lachy.id.au
Sun Sep 4 15:48:59 PDT 2005
Anne van Kesteren wrote:
> Quoting Kornel Lesinski <kornel at ideadesigners.com>:
>> 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.
The problem is that white space handling in parameter values isn't
currently defined at all, and I implemented it assuming that each
parameter value would contain only one class name. Handling the
(currently) erroneous parameter ("foo bar")is basically a form of error
recovery, and the fact that it returns anything at all is merely a
result of how the regex is constructed using it.
Before I can fix the implementation in any way, I need to know how white
space should be handled before (" foo"), after ("foo ") and inside ("foo
bar") the parameter value. At the moment I trim any leading and
trailing spaces in most cases (there's currently a bug that stops it
working sometimes), but I don't really handle white space inside very well.
("foo bar") could basically be handled in the following ways and I need
to know which:
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.
More information about the whatwg