W3C home > Mailing lists > Public > public-webapps@w3.org > April to June 2011

Support for matchesSelector()

From: Lachlan Hunt <lachlan.hunt@lachy.id.au>
Date: Fri, 08 Apr 2011 15:44:07 +0200
Message-ID: <4D9F1127.3060201@lachy.id.au>
To: public-webapps <public-webapps@w3.org>
Hi,
   The matchesSelector() method has been implemented by both Mozilla [1] 
and WebKit [2], and we are implementing the same level of support for it 
as they did (without support for :scope or refNodes parameter).

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?

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

1. Using refNodes without using the :scope selector has no effect and 
additional parameters are just ignored.

   e.g. el.matchesSelector("a", [el1, el2]); works now as defined.

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

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.

e.g.
   try {
     var x = el.matchesSelector(":scope>a", [el1]);
   } catch (e) {
     // Use alternative technique here to check.
   }

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.

Therefore, I would like to get feedback from others, particularly the 
Mozilla and WebKit developers about this approach, and find out whether 
Mozilla and WebKit will also consider dropping the prefix?

[1] https://bugzilla.mozilla.org/show_bug.cgi?id=518003
[2] https://bugs.webkit.org/show_bug.cgi?id=29703

-- 
Lachlan Hunt - Opera Software
http://lachy.id.au/
http://www.opera.com/
Received on Friday, 8 April 2011 13:44:33 GMT

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