Re: Making selectors first-class citizens

On 11/09/2013 17:22 , Boris Zbarsky wrote:
> On 9/11/13 9:52 AM, Rick Waldron wrote:
>> A prime use case: a cache of selector objects that are useful when
>> matching event.target for event handler delegation patterns.
>
> Note that UAs already do some internal caching of parsed selector
> objects used with querySelector.  Of course an explicit cache in the
> script would likely be a tiny bit faster.

On IRC Domenic pointed out that the primary apparent usage for this 
mirrors jQuery's .is(). Barring the caching case, it seems unlikely to 
be appealing to do (new Selectors("div")).matches(el) instead of 
el.matches("div").

One thing that /could perhaps/ be interesting with this though would be 
as an extensibility point in which developers could bind parameters and 
functions extending selectors. A selector object would be a logical 
place to hang this off of. But that's a whole other kettle of fish.

-- 
Robin Berjon - http://berjon.com/ - @robinberjon

Received on Wednesday, 11 September 2013 20:49:56 UTC