[whatwg] getElementsByClassName()

On Fri, 03 Feb 2006 15:31:37 +0200, Ric Hardacre <whatwg at cycloid.f9.co.uk>  
wrote:

> this also raises the possibility of some confusion as the order of  
> inheritance is important:
>
> foo
> {
>     color: red;
> }
>
> bar
> {
>     color: blue;
> }
>
> in the quoted example Fred and Wilma would be blue and barney red. so  
> the distinction between class="foo bar" and class="bar foo" is real, not  
> merely syntactic. a search for "foo" should pick up either but a search  
> for "foo bar" should only find the first, so IMO a comma seperated list  
> would be better in that respect:
>
> 1. getElementsByClassName("foo bar,foo tang,woo tang")
>
> this use of explicit class matching could, however be considered an  
> "advanced" use of the function, with emphasis on the simpler:
>
> 2. getElementsByClassName("bar,tang")
>
> as an aside this then yields another level of even more complex  
> behavioural possibilities:
>
> 3. getElementsByClassName("foo>bar")
>
> though in this example the ClassName, having not being explicitly  
> declared in the markup. is not what is being selected, but a derived  
> inheritance, perhaps warranting a new function
>
> 4. getElementsByRelationship("foo:firstChild")
>
> what this would mean, therefore is that
>
> 5. <div class="foo bar">
>
> would be selected by example 1. whereas
>
> 6. <div class="foo"><div class="bar">
>
> would be selected by example 3. specifically and example 4. if the  
> designer wanted to make assumptions about the resuting DOM
>
> Ric
>

This is way too wild :).

A comma separated list, or any list separated by any other character can't  
be used. The reason has been over-stated (search the mailing list):  
basically who what if some other styling language defines that class names  
can contain the space char, or the comma char?

AFAIK, Ian said that something like getElementsCSSselector() is something  
for the CSS WG from W3C. Defining getElementsByRelationship() would  
already "touch" that subject. He only wants to define  
getElementsByClassNames().

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

Received on Friday, 3 February 2006 05:44:27 UTC