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

Re: [selectors-api] Summary of Feature Requests for v2

From: Sean Hogan <shogun70@westnet.com.au>
Date: Fri, 25 Sep 2009 09:46:13 +1000
Message-ID: <4ABC04C5.5020702@westnet.com.au>
To: Lachlan Hunt <lachlan.hunt@lachy.id.au>
CC: Mike Wilson <mikewse@hotmail.com>, 'public-webapps' <public-webapps@w3.org>
Lachlan Hunt wrote:
> Mike Wilson wrote:
>> My first priority would be "Matches Selector", and see to that
>> it fulfills the needs for event delegation.
>
> Is there any special functionality that would be needed to achieve 
> this?  If I understand correctly, event delegation just needs to be 
> able to check whether the event target element matches a given 
> selector.  So it would be something like:
>
> if (evt.target.matchesSelector(".foo>input.bar")) {
>    ...
> }
>

In case it isn't obvious, we may want to check every element in the 
event path. i.e. all ancestors of  evt.target.

If matchesSelector could be called with a context element then it would 
become a more powerful version of compareDocumentPosition(). It is also 
more limited because you can't do preceding-siblings.

Examples
I'll use the :scope pseudo-class, although :context would be a better name.

elt.matchesSelector(":scope *", context); // descendant
elt.matchesSelector(":scope > * *", context); // descendant but not child
elt.matchesSelector(":scope ~ *", context); // following-sibling
elt.matchesSelector(":scope ~ * > *", context); // nephew (child of a 
following-sibling)

I would probably use it if it was there, but wouldn't complain if it 
wasn't.
Received on Thursday, 24 September 2009 23:46:55 GMT

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