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

Garrett Smith wrote:
> On Thu, Sep 24, 2009 at 12:02 AM, Mike Wilson <mikewse@hotmail.com> wrote:
>   
>> Yes, the base for event delegation is certainly something
>> like that. I just wanted to make clear that the main reason
>> for adding this functionality (IMO) is event delegation.
>> I'll let event delegation library creators chime in on the
>> details on what is needed for making really efficient
>> behavioural/delegation implementations, and judge the merits
>> of various optimizations. There has f ex already been mention
>> of caching "parsed" selectors.
>>
>>     
>
> The benefit to that is that the selector text is parsed once, so
> something like:-
>
> document.onmouseover = function(ev) {
>   if(ev.target.matchesSelector(".infotip")) { /*...*/ }
> };
>
> could probably be made more efficient as:-
>
> var selector = QuerySelector.create(".infotip");
> document.onmouseover = function(ev) {
>   if(selector.matches(ev.target)) { /*...*/ }
> };
>
>   

I would be surprised if an implementation didn't create an internal 
lookup table keyed off the selector text.

Received on Thursday, 24 September 2009 10:29:52 UTC