Re: Supporting Scoped Selectors in Selectors API 2

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 UTC