Re: [selectors-api] Matching subtrees or not

On Nov 19, 2008, at 11:02 AM, Boris Zbarsky wrote:
> Gavin Kistner wrote:
>> Section 6 states:
>> "The querySelector() method ... must ... return the first matching  
>> Element node ***within the node’s subtree***." [1]
>
> That's correct.  The Element must be matching, and must be inside  
> the subtree rooted by the context node.
>
>> "Even though the method is invoked on an element, ***selectors are  
>> still evaluated in the context of the entire document***.
>
> This is also correct.  Determining whether an Element is matching  
> does not use the context node in any way (modulo a possible :context  
> selector in the future).
>
> I don't see a contradiction here.


Thank you for the confirmation that led to me re-examining what the  
example was trying to show. I was assuming that the context of the  
method receiver was used as the implicit root of the selector. I see  
now that the entire document is searched but the result is intersected  
with the receiver's subtree. (Though, of course, that may not be the  
exact implementation.)

I officially withdraw my comment. (Perhaps I may think of and suggest  
a way to make the example more clear. One way might be to have a  
unique element as a child of the receiver div, and select that instead  
of p elements.)

Received on Wednesday, 19 November 2008 21:52:36 UTC