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

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 UTC