Re: Support for matchesSelector()

On 4/8/11 6:44 AM, Lachlan Hunt wrote:
> However, both Mozilla and WebKit opted to implement it using prefixed
> methods, and I'm wondering if people from Mozilla and WebKit could
> explain their justification for using a prefix?

Sure.  In Gecko's case, we implemented in October 2009.  The first spec 
draft that mentions matchesSelector appeared in January 2010.  So at the 
time we were implementing, there was no indication that the name, the 
number of arguments, the meaning of the arguments, etc would not change 
as said spec draft was written.

> We are thinking that implementing with a prefix as
> Element.oMatchesSelector() is unnecessary

Well, one obvious question is whether we now have good reasons to 
believe that the name and number/meaning of the arguments won't change.

> 2. Using the :scope selector in existing implementations will throw a
> syntax error.

That seems, to me, like something that should prevent unprefixing, no?

> This means that if a script in the future wants to use a selector with
> :scope, they will still be able to detect whether or not a given browser
> supports it using a try/catch block.

Yes, but should it have to?

> 3. The existing querySelector methods also don't have a prefix, but
> selectors api 2 also extends those in the same way with refNodes. This
> should not be a problem for those methods.

This is true, for the reasons you described, but trying to use the new 
features for the existing methods does involve that try/catch pattern 
you noted.  But should we really require its use for matchesSelector? 
There are obvious benefits to having matchesSelector support imply that 
:scope is supported too...

I should note that the way the old methods were extended is somewhat 
worrisome: as soon as a UA implements the new refNodes thing we're stuck 
with it.  So I really hope that either we're very sure that's what we 
want to do or that UAs are careful about implementing until we get to 
that "very sure" level.  I'd prefer the former, since I've been 
considering implementing this stuff.

-Boris

Received on Friday, 8 April 2011 14:42:16 UTC