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

Re: [selectors-api] Why no querySelector(All) on DocumentFragments?

From: Ian Hickson <ian@hixie.ch>
Date: Fri, 14 Mar 2008 01:10:57 +0000 (UTC)
To: Boris Zbarsky <bzbarsky@MIT.EDU>
Cc: liorean <liorean@gmail.com>, "Web APIs WG (public)" <public-webapi@w3.org>
Message-ID: <Pine.LNX.4.62.0803140109440.17076@hixie.dreamhostps.com>

On Wed, 12 Mar 2008, Boris Zbarsky wrote:
> 
> javascript:var n = 
> document.createElement("div");n.appendChild(document.createElement("span"));alert(n.querySelector(":root 
> span"));
> 
> Webkit nightly returns null.  IE throws (no :root support).  Gecko 
> prototype implementation returns the span, since :root will match any 
> node with no ancestors.

Webkit is correct. The Selectors spec defines :root as:

   "The :root pseudo-class represents an element that is the root of the 
   document."

...and here, the span is not the root of the document, it's just an 
unconnected element owned by the document.

Thus it is possible for an element to match neither "* > *" nor ":root".

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'
Received on Friday, 14 March 2008 01:25:56 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 14 March 2008 01:25:57 GMT