Re: [selectors] Tree selectors

Anne van Kesteren wrote:
> 
> The current Selectors specification ([css3-selectors]) defines various 
> methods for selecting siblings using :nth-child. However, it does not 
> define such a method for trees. For example:
> ...
> ... there is no way to select all "even" or all "odd", which is possible 
> when you do not have a tree but a list of siblings:
> 
> ... I think some :depth(arg) pseudo-class or other method should be 
> designed to have similar options for trees.

I proposed a several similar ideas to this in 2003-12.  One used several 
pseudo-classes for selecting various nth-decendants (like nth-child, but 
working with trees like :depth()) and another using a combinator.  As 
was discussed in the thread [1], the pseudo-classes were innappropriate, 
specifically for the reasons given by Ernest Cline [2].  I believe, if 
I'm understanding this proposal and this is in any way similar to my 
earlier proposals, this wouldn't wouldn't work for the same reason.

However, I think the combinator idea I had, which wasn't discussed much 
(nor rejected) at the time may still be a good idea, and it may be able 
to achieve the desired result of :depth().

In summary, the combinator (^) idea [3] was this:
body > section ^ section

Would select the second level section element, regardless of any 
elements in between.

eg.

<body>
   <section>
     <div>
       <section> <-- Selects this one -->

I think this would be equivlent to the proposed selector:
   section:depth(2)
(that is, if I understood :depth() correctly).

[1] http://lists.w3.org/Archives/Public/www-style/2003Dec/thread.html#34
[2] http://lists.w3.org/Archives/Public/www-style/2003Dec/0063.html
[3] (Specifically, the section under the heading "-- Combinator --")
     http://lists.w3.org/Archives/Public/www-style/2003Dec/0034.html

-- 
Lachlan Hunt
http://lachy.id.au/
http://GetFirefox.com/     Rediscover the Web
http://GetThunderbird.com/ Reclaim your Inbox

Received on Saturday, 2 April 2005 11:57:25 UTC