W3C home > Mailing lists > Public > public-webapps@w3.org > July to September 2009

Re: [selectors-api] Scoped Selectors

From: Sean Hogan <shogun70@westnet.com.au>
Date: Fri, 25 Sep 2009 20:42:06 +1000
Message-ID: <4ABC9E7E.3010207@westnet.com.au>
To: Lachlan Hunt <lachlan.hunt@lachy.id.au>
CC: public-webapps <public-webapps@w3.org>
Sean Hogan wrote:
> Hi Lachy,
>
> Here's a proposal.
>
> querySelector*(selector, context) // allows selectors with :scope 
> pseudo-class
> queryScopedSelector*(selector, context) // allows selectors with 
> implied :scope
> matchesSelector(selector, context) // allows selectors with :scope 
> pseudo-class
>
> To check if the :scope pseudo-class is available, use:
>
> try { document.body.matchesSelector(":scope", document.body); }
> catch (error) { /* not supported */ }
>
>  OR
>
> try { document.querySelector(":scope", document.body); }
> catch (error) { /* not supported */ }
>
Sorry. Replace document.body with document.documentElement. That should 
be more efficient for the querySelector test.
Received on Friday, 25 September 2009 10:42:47 GMT

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