W3C home > Mailing lists > Public > public-webapps@w3.org > October to December 2011

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

From: Jonas Sicking <jonas@sicking.cc>
Date: Thu, 10 Nov 2011 23:33:15 -0800
Message-ID: <CA+c2ei9RKg2XhSeQZ-JH_X4Ge9OtAL5-_ZPypanKsHHXxeF2YA@mail.gmail.com>
To: Travis Leithead <travis.leithead@microsoft.com>
Cc: "public-webapps@w3.org" <public-webapps@w3.org>
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?

While related, I think the question of how <style scoped> rules are
parsed is somewhat independent.

> 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)

Here is my detailed proposal based on the previous thread for how
selector parsing should work in the context of .find/.findAll:

1. Start with an empty list
2. Skip any whitespace at the beginning of the string.
3. If the next character is a ">", a "+" or a "~", insert a "simple
selector"[1] containing just the ":scope" pseudo selector at the
beginning of the selector.
4. Parse as a "selector"[1]. If there's a parse error throw an
SyntaxError exception.
5. If during parsing a ":scope" pseudo class was parsed, and if a
":scope" pseudo selector was added in step 2, throw a SyntaxError
exception.
6. If during parsing no ":scope" pseudo class was parsed, and if no
":scope" pseudo selector was added in step 2, add a simple selector
containing just the ":scope" pseudo class to the beginning of the
list, and use a descendant selector as combinator to the rest of the
selector.
7. Add selector to the end of list created in step 1.
8. If, after skipping any whitespace, the next character is a comma,
skip the comma and go to step 2.

The resulting selector list is evaluated against the document node,
but with :scope matching the node that .find/.findAll was called on.
.findAll returns all nodes which match the selector in document order.
.find returns the first node in the list of nodes that .findAll
returns, or null if the list is empty.

Now, as for what type .findAll should return is a so far unresolved
question. I'll start a separate thread on that.

/ Jonas
Received on Friday, 11 November 2011 07:34:14 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:48 GMT