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

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

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Wed, 12 Mar 2008 22:48:18 -0500
Message-ID: <47D8A402.2050104@mit.edu>
To: liorean <liorean@gmail.com>
CC: "Web APIs WG (public)" <public-webapi@w3.org>

liorean wrote:
> Isn't this approach potentially much more resource intensive though?

Not for the typical browser workload, which is to match a node to a whole bunch 
of rules....  So I guess it depends on whether querySelector reuses the existing 
selector matching code.

> The Selectors spec doesn't really deal with the DOM though.

But it does.  It's all in terms of a tree and stuff..  The question is whether 
the "tree" for a node is the tree rooted by its ownerDocument or the connected 
tree containing the node.

I should note that interoperability for detached subtrees is pretty poor.  For 
example, consider the following:

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.

So I do think that the spec needs a lot more detail here...

-Boris
Received on Thursday, 13 March 2008 03:49:00 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Thursday, 13 March 2008 03:49:01 GMT