W3C home > Mailing lists > Public > www-style@w3.org > September 2009

Re: Supporting Scoped Selectors in Selectors API 2

From: Andrew Fedoniouk <news@terrainformatica.com>
Date: Mon, 28 Sep 2009 09:35:29 -0700
Message-ID: <4AC0E5D1.6010908@terrainformatica.com>
To: Lachlan Hunt <lachlan.hunt@lachy.id.au>
CC: www-style <www-style@w3.org>
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.

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

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:07:39 UTC