Skip to content

Commit 9b67b4c

Browse files
committed
Fix #12436, make delegated events fast again. Close jquerygh-923.
Retains the rooted-at-delegateTarget behavior fixed in #12383 by afd717d.
1 parent c79a533 commit 9b67b4c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/event.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ jQuery.event = {
8181
handler: handler,
8282
guid: handler.guid,
8383
selector: selector,
84+
needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
8485
namespace: namespaces.join(".")
8586
}, handleObjIn );
8687

@@ -393,7 +394,9 @@ jQuery.event = {
393394
sel = handleObj.selector;
394395

395396
if ( selMatch[ sel ] === undefined ) {
396-
selMatch[ sel ] = jQuery( sel, this ).index( cur ) >= 0;
397+
selMatch[ sel ] = handleObj.needsContext ?
398+
jQuery( sel, this ).index( cur ) >= 0 :
399+
jQuery.find( sel, this, null, [ cur ] ).length;
397400
}
398401
if ( selMatch[ sel ] ) {
399402
matches.push( handleObj );

0 commit comments

Comments
 (0)