W3C home > Mailing lists > Public > whatwg@whatwg.org > November 2005

[whatwg] 2.2.6. The document - getElementsByClassName

From: ROBO Design <robodesign@gmail.com>
Date: Mon, 07 Nov 2005 17:12:28 +0200
Message-ID: <op.szvlu2sxmapogm@duron.mshome.net>
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
Received on Monday, 7 November 2005 07:12:28 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:58:43 UTC