]> source.dussan.org Git - jquery.git/commitdiff
Fix #12436, make delegated events fast again. Close gh-923.
authorDave Methvin <dave.methvin@gmail.com>
Mon, 10 Sep 2012 00:47:07 +0000 (20:47 -0400)
committerDave Methvin <dave.methvin@gmail.com>
Mon, 10 Sep 2012 01:21:42 +0000 (21:21 -0400)
Retains the rooted-at-delegateTarget behavior fixed in #12383 by afd717df9e.

src/event.js

index 902b2b5ffaf875a34e432dc64ff7d61fd3f5d8c1..d4c17cf31ba0e7fc69542fc1e339c494fc2bfd38 100644 (file)
@@ -81,6 +81,7 @@ jQuery.event = {
                                handler: handler,
                                guid: handler.guid,
                                selector: selector,
+                               needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
                                namespace: namespaces.join(".")
                        }, handleObjIn );
 
@@ -393,7 +394,9 @@ jQuery.event = {
                                                sel = handleObj.selector;
 
                                                if ( selMatch[ sel ] === undefined ) {
-                                                       selMatch[ sel ] = jQuery( sel, this ).index( cur ) >= 0;
+                                                       selMatch[ sel ] = handleObj.needsContext ?
+                                                               jQuery( sel, this ).index( cur ) >= 0 :
+                                                               jQuery.find( sel, this, null, [ cur ] ).length;
                                                }
                                                if ( selMatch[ sel ] ) {
                                                        matches.push( handleObj );