Re: Supporting Scoped Selectors in Selectors API 2

Lachlan Hunt wrote:
...
> 
> var elm = document.getElementById("foo");
> elm.querySelector(">em, >strong");
> ems.querySelector("+p");
> ems.querySelector("~p");
> 
> These are pre-processed and interpreted as being equivalent to 
> ":reference>em, :reference>strong", ":reference+p" and ":reference~p", 
> respectively, where :reference matches the element elm.  This is 
> designed to be more compatible with how JavaScript libraries operate.
> 
> Because the descendant combinator can't work in the same way, I've used 
> the exclamation point character as an indicator that it is intended to 
> be a scoped selector.
> 
> e.g.
> elm.querySelector("!div div, div p");
> 
> That is interpreted as being equivalent to:
>   ":reference div div, :reference div p".
> 
> This character was chosen because it currently can't appear at the 
> beginning of a conforming group of selectors.  But it also makes the 
> assumption that future selector syntax will never allow a selector to 
> begin with an exclamation point, or at least not in a way that would 
> clash with its use here.

I believe that it is better to use "standalone colon" as a designator of
the :lookup-root (a.k.a. :reference or :principal)

elm.querySelector(": div div, : div p");
elm.querySelector(": > em, :> strong, :+code");

Such construction definitely will not conflict with any future selectors.

More strong (grammatically) alternative is "::" - double colons.

> 
> I would like to find out if the CSSWG finds this acceptable, or if I 
> should try to find an alternative solution.
> 


-- 
Andrew Fedoniouk.

http://terrainformatica.com

Received on Monday, 28 September 2009 16:35:56 UTC