Re: [selectors-api] QSA and findAll definitions

On Mon, Jun 10, 2013 at 1:15 PM, Timmy Willison <timmywillisn@gmail.com> wrote:
> Thank you both. That helps a lot. I figured el.querySelector(":scope + div")
> would do the same thing as el.find("+ div").
>
> Perhaps more examples in the spec that clearly demonstrate differences like
> this between qSA() and findAll() would be helpful. I think some form of the
> example that Tab gave would be a great addition.
>
> Also, maybe we can clarify even further in the defintions for find() and
> findAll(). Perhaps, rather than,
>
> "... from the tree within which the context object is located."
>
> It could be,
>
> "... within the subtrees of the parent of the context object or the tree in
> which the context object is located if there is no parent."
>
> Compare this with qS[A]:
>
> "... within the subtrees of the context object."
>
> This is an attempt to make it clear that ancestors of the context object
> will never be in the resulting set and need not be considered in
> implementations. In other words, it seems to me that elem.find() will never
> return ancestors of elem.

It certainly can return ancestors.  You just need the right
combinators.  The reference combinator defined in Selectors 4
<http://dev.w3.org/csswg/selectors/#idref-combinators> can move
anywhere in the tree, including straight upwards.  The use of the
subject indicator, also defined in Selectors 4
<http://dev.w3.org/csswg/selectors/#subject>, can also move up the
tree.

Just throw away your notion that .find() does any scoping whatsoever.
It doesn't; all it does is provide a reference element, which is
matched by :scope and which is used to absolutize relative selectors.

~TJ

Received on Monday, 10 June 2013 20:48:39 UTC