W3C home > Mailing lists > Public > public-webapi@w3.org > April 2008

Re: [SelectorsAPI] Thoughts on querySelectorAll

From: Jonas Sicking <jonas@sicking.cc>
Date: Wed, 30 Apr 2008 15:39:31 -0700
Message-ID: <4818F523.4010205@sicking.cc>
To: John Resig <jresig@mozilla.com>
CC: "L. David Baron" <dbaron@dbaron.org>, public-webapi@w3.org

John Resig wrote:
>> But that would mean that .querySelectorAll(":root div") would never 
>> match anything since :root (or :scope) could only match the element 
>> itself, which of course isn't a descendant.
> I was under the impression that within the context of a DOM element :root would be equivalent to the root element itself - not the document element.


> Thus these two would be equivalent (returning the same sets of elements):
>   document.getElementById("test").getElementsByTagName("div")
>   document.getElementById("test").querySelectorAll(":root div")
> If that's not the case then disregard all of the previous ":root is a good solution" talk, because that's what I was basing this on.

There are two contrary statements in your proposal.

":root" matches the root element (i.e. the "test" element in your example)

All simple selectors has to match a descendant of the element on which 
.querySelectorAll was called.

Clearly the "test" node isn't a descendant of itself, so the ":root" 
part couldn't match anything.

/ Jonas
Received on Wednesday, 30 April 2008 22:40:56 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:16:26 UTC