[whatwg] 2.2.6. The document - getElementsByClassName

Anne van Kesteren fora at annevankesteren.nl
Mon Nov 7 07:55:05 PST 2005


Quoting ROBO Design <robodesign at gmail.com>:
> Also, class names cannot contain spaces (AFAIK). Therefore, what are 
> the  arguments for having multiple arguments instead of a single one?

You're talking about "class names" but you're not referring to any particular
language. And that is the problem. There might very well be a language which
defines class names which can contain spaces, but not a horizontal pipe for
example, because that is used to separate the classes.


> b) Idea: getElementsByClassName() could accept multiple argument, 
> each  argument being a class name. The only difference from the 
> current  definition of the spec: if any argument contains space 
> characters, split  the string into an array and consider them as 
> multiple class names.
>
> getElementsByClassName("we all like dogs") =
> getElementsByClassName("we", "all", "like", "dogs") =
> getElementsByClassName("we all", "like dogs")
>
> In this way you satisfy everybody.

See above. Also, this makes it less clear imho. For example
getElementsByClassName("foo bar"); // using your syntax
... would still match
class="bar foo"


>> We could also have a getElementBySelector() method, but it seems 
>> that it  would be best to let the CSSWG define that.
>
> The specification already defined getElementsByClassName(). So, why 
> not  getElementsBySelector() too? Or this can be better handled via 
> XPath  expressions?

As stated, the CSS WG might do that. (I believe Daniel Glazman wants it in
eventually.)

Cheers,

Anne


-- 
Anne van Kesteren
<http://annevankesteren.nl/>




More information about the whatwg mailing list