Re: QSA, the problem with ":scope", and naming

On Thu, Nov 10, 2011 at 2:57 PM, Travis Leithead
<travis.leithead@microsoft.com> wrote:
> This has been an interesting debate, but I'm still a little confused with the outcome (if any).
>
> Will someone summarize the current position on these issues:
>
> 1. Should "find()" and "findAll()" follow <style scoped> rules or not and how?
> 2. How does the presence of ":scope" affect "find()" and "findAll()"
> 3. Should "invalid" selectors be allowed (those that start with a combinator)? (I'm not quite sure where that landed)
>
> And finally...
> When can we expect to see a draft proposal of "find()" and "findAll()" in Selectors API L2?

This is based on my understanding of the thread's conclusion.

1. Almost, though with a few small differences due to slightly
different affordances.  Specifically:
  a. Normal selectors (without :scope in them) will *not* match the
context element - you have to use :scope specifically to refer to the
context.  This was chosen so that the common case of "el.find('div')"
won't just return the context element when it's a div.  <style scoped>
goes the opposite way largely for forwards compat, so people can use
the #id of the context during the interim period
  b. You can select elements outside of the context element.  The
search starts at the context, but you can use a sibling or reference
combinator to select outside the subtree.  This is because it's
useful, and also because it allows one to "interrupt" a selector at
any point, do some work on the set, and then continue with the rest of
the selector, regardless of what the selector's structure was.

2. The presence of :scope lets you select the context element, or
specialize on it.  It hasn't been fully decided whether :scope is
required to be at the start of the selector when it's present or if it
can occur anywhere (in which case it switches the selector to matching
over the whole document).

3. Yes, they should be.  Everyone's used to them from jQuery, so why not?

~TJ

Received on Thursday, 10 November 2011 23:21:44 UTC