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

Re: Supporting Scoped Selectors in Selectors API 2

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Tue, 29 Sep 2009 13:21:36 -0500
Message-ID: <dd0fbad0909291121k6b9b85dcgd4c7e26cb6bb7948@mail.gmail.com>
To: fantasai <fantasai.lists@inkedblade.net>
Cc: Lachlan Hunt <lachlan.hunt@lachy.id.au>, www-style <www-style@w3.org>
On Tue, Sep 29, 2009 at 1:04 PM, fantasai <fantasai.lists@inkedblade.net> wrote:
> Lachlan Hunt wrote:
>> As I said, the boolean flag parameter provided absolutely no way for
>> scripts to detect whether or not implementations support scoped selectors.
>>  Using the syntactic flag instead at least caused a syntax error to be
>> thrown by existing implementations, allowing scripts to catch it and resort
>> to fallback behaviour.
>
> Maybe you can't do this, but if you put the flag first then that will
> trigger an exception in existing implementations.
> (Not that I'm particularly in favor of this solution in any case.)

Actually, you can feature-test for this pretty easily, especially if
it works on document fragments.  Just create a document fragment like
"<div><div></div></div>", grab the inner div and check what
querySelector("div div",{"scoped":true}) on it returns.  If you get an
element, the implementation doesn't support the flag.  Authors are
already used to feature-testing, and this is the sort of thing that
can easily be dropped into Modernizr or similar.

~TJ
Received on Tuesday, 29 September 2009 18:22:43 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:21 GMT