Re: Supporting Scoped Selectors in Selectors API 2

On Mon, Sep 28, 2009 at 6:49 PM, Lachlan Hunt <lachlan.hunt@lachy.id.au> wrote:
> It might appear to work for the simple case above, but consider the
> following cases:
>
> elm.querySelectorAll(":reference+p, div div");
>
> Or the reverse of that:
>
> elm.querySelectorAll("div div, :reference+p");

I'm not sure what the problem here is.  Surely you have to parse the
entire string before starting *anyway*.  What's wrong with saying
that, if :reference is found anywhere in the selector, it's a scoped
selector string?

> As defined, for non-scoped selectors, the implementation only needs to test
> descendants of elm.  For scoped selectors, it needs to check the whole tree
> (or at least the element's descendants, siblings and their descendants).

It only needs to do so if it detects something starting with +, ~,
:reference+, or :reference~.  Otherwise it can just look at
descendants, same as normal querySelector.

~TJ

Received on Tuesday, 29 September 2009 00:47:54 UTC