- From: Tab Atkins Jr. <jackalmage@gmail.com>
- Date: Mon, 14 Jan 2013 22:01:00 -0800
- To: Lachlan Hunt <lachlan.hunt@lachy.id.au>
- Cc: www-style <www-style@w3.org>
On Mon, Jan 14, 2013 at 6:05 AM, Lachlan Hunt <lachlan.hunt@lachy.id.au> wrote: > On 2012-10-30 11:42, Lachlan Hunt wrote: >> Additionally, I would like to move the definition for relative selectors >> and the related parsing to Selectors 4. This is a concept I defined in >> Selectors API Level 2, which basically allows selectors to begin with a >> combinator and have an implied :scope. >> >> http://dev.w3.org/2006/webapi/selectors-api2/#grammar > > I see that Selectors 4 has since introduced the concept of > "scope-relative selectors", which seems to be what I was asking for. > Though, there are some issues with the way it is currently written. > > http://dev.w3.org/csswg/selectors4/#scoping > > Firstly, the example in this section states that element.find() uses > scope-contained selectors like scoped stylesheets in HTML. But it > doesn't. It uses scope relative selectors. These are different because > .find() needs to be able to match elements that are not descendants of > the context object. Sorry, I believe that was an oversight, since that example was written before we added scope-relative. Fixed now. > Secondly, the current scope-relative selector definition states: > >> With this method of scoping, ":scope " (the :scope pseudo-class >> followed by a space) is implied at the beginning of each complex >> selector, allowing them to begin syntactically with a combinator. The >> scoping element matches this implied :scope selector, but does not >> limit which elements match. > > The find(), findAll() and matches() methods were designed with special > rules that defined when :scope should and should not be prepended to > each selector, which are not properly covered by the above definition. > These are the rules used in Selectors API: > > --- > > 1. If the relative selector begins with a combinator, then prepend the > simple selector ":scope" to the relative selector. > > 2. Otherwise, if the reference nodes is an empty collection, do nothing. > > 3. Otherwise, if any compound selector within relative selector > includes a functional pseudo-class that accepts a selector as its > parameter, and which contains the ":scope" pseudo-class anywhere > within it, then do nothing. > > 4. Otherwise, if the relative selector includes :scope within any > compound or simple selector, then do nothing. > > 5. Otherwise, if the scope flag is set, prepend the simple selector > ":scope" and a descendant combinator (' ') to the relative selector. That phrasing was intentional, but I don't recall why. I remember that fantasai and I argued about it, though. fantasai, any insights? ~TJ
Received on Tuesday, 15 January 2013 06:01:46 UTC