[whatwg] 2.2.6. The document - getElementsByClassName

ROBO Design robodesign at gmail.com
Mon Nov 7 07:12:28 PST 2005


Hello!

I have read 2.2.6. The document [1] and I have the following to say:

a) getElementsByClassName()
http://www.whatwg.org/specs/web-apps/current-work/#getelementsbyclassname

> There is an open issue on whether we should use multiple arguments or  
> just one argument that needs to be split on spaces.

This shouldn't be a big issue at all.

I opt for using just one argument with multiple class names separated with  
a space.

I wouldn't like having multiple arguments, because when authors need to  
get a list of elements based on multiple class names, and the number of  
classes is not known by the author before writing the script, s/he's  
required to use eval(). This sucks IMHO :).

Also, class names cannot contain spaces (AFAIK). Therefore, what are the  
arguments for having multiple arguments instead of a single one?


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.

c)

> 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?


[1] http://www.whatwg.org/specs/web-apps/current-work/#the-document

-- 
http://www.robodesign.ro
ROBO Design - We bring you the future



More information about the whatwg mailing list