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 17:30:27 -0500
Message-ID: <47D85983.3000108@mit.edu>
To: liorean <liorean@gmail.com>
CC: "Web APIs WG (public)" <public-webapi@w3.org>

liorean wrote:
> In this traversal scheme, querying the selector is still done from the
> document node, just excluding all subtrees except for the subtree of
> the element we're querying on.
> Another alternative is of course to do the matching backwards,
> beginning with trying to match the last simple selector in the
> selectors on each of the elements of the subtree in question, then
> traversing the tree in upwards direction.

Indeed.  I believe the backwards approach is what UAs actually do, and 
what makes the most sense to do.  That is, the real question is whether 
there is a subset of the maximal connected subtree containing the given 
node (the one on which querySelector is being called) such that this 
subset consists of nodes which match the various sequences of simple 
selectors involved, and are positioned as required by the combinators, 
with the element matching the rightmost sequence of simple selectors a 
descendant of the given node.  If so, that element matches the selector.

If Selectors does not define this sort of thing (and as I recall it 
actually doesn't), then selectors api might need to.  It would make the 
most sense to define this in Selectors, however.

Received on Wednesday, 12 March 2008 22:30:53 UTC

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