W3C home > Mailing lists > Public > www-style@w3.org > July 2008

Re: Opera's Proposal for :context Selector

From: Brad Kemper <brkemper@comcast.net>
Date: Fri, 11 Jul 2008 08:50:27 -0700
Cc: Andrew Fedoniouk <news@terrainformatica.com>, www-style <www-style@w3.org>
Message-Id: <A29018EA-A3D9-432F-B701-11FD896A414A@comcast.net>
To: Lachlan Hunt <lachlan.hunt@lachy.id.au>


On Jul 11, 2008, at 12:01 AM, Lachlan Hunt wrote:

>>> If :root were redefined as you suggest, then so would this would  
>>> need to as well:
>>>
>>> foo.querySelector("body :root div");
>> No. That is invalid selector. :root can only be defined for the  
>> very first element of the selector. Otherwise it makes no sense -  
>> will always be false.
>
> Yes, I know :root can only be the first element, which is why I'm  
> saying it can't be used in this case!

Since querySelector() is still experimental, it can still be changed.  
Could the CSS WG say that in the case of selectors that are used in  
fragments such as this, that :root refers to the root of the fragment,  
in this case the element represented by "foo"? So in that case the  
following should do what you want:

foo.querySelector(":root div");

> In that particular case, yes, it's entirely redundant.  But consider  
> this case:
>
> foo.querySelectorAll(".foo :context>.xxx, .bar :context>.yyy");

If :root referred to the fragment root, and something with class "bar"  
was its ancestor in the document as a whole, then in theory that could  
be written as follows:

foo.querySelectorAll(":root>.xxx, .bar :root>.yyy");

...unless the querySelectorAll and querySelector prevent you from  
querying selectors that include the parents or ancestors of the  
element itself as part of the selection pattern.
Received on Friday, 11 July 2008 15:51:10 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:55:10 GMT