Re: Opera's Proposal for :context Selector

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 UTC