diff options
author | Dave Methvin <dave.methvin@gmail.com> | 2011-11-13 20:50:36 -0500 |
---|---|---|
committer | Dave Methvin <dave.methvin@gmail.com> | 2011-11-13 20:50:36 -0500 |
commit | 683be093a675d2b8b65d5a33c3416cbe99a71967 (patch) | |
tree | 085f820f6d6e290f7cdd31c5194badf629b9feec /src/event.js | |
parent | e0a4aa415d988b21c5b666a20ab00823673ffc3d (diff) | |
download | jquery-683be093a675d2b8b65d5a33c3416cbe99a71967.tar.gz jquery-683be093a675d2b8b65d5a33c3416cbe99a71967.zip |
Catch more cases where special events were incorrectly removed.
We can't take the blow-it-all-away shortcut because something in the middle of the list may be a mapped special event. On the bright side, -22!
Diffstat (limited to 'src/event.js')
-rw-r--r-- | src/event.js | 35 |
1 files changed, 15 insertions, 20 deletions
diff --git a/src/event.js b/src/event.js index e95707563..d56c44a55 100644 --- a/src/event.js +++ b/src/event.js @@ -180,28 +180,23 @@ jQuery.event = { origCount = eventType.length; namespaces = namespaces ? new RegExp("(^|\\.)" + namespaces.split(".").sort().join("\\.(?:.*\\.)?") + "(\\.|$)") : null; - // Only need to loop for special events or selective removal - if ( handler || namespaces || selector || special.remove || origType !== type ) { - for ( j = 0; j < eventType.length; j++ ) { - handleObj = eventType[ j ]; - - if ( origType === handleObj.origType && - ( !handler || handler.guid === handleObj.guid ) && - ( !namespaces || namespaces.test( handleObj.namespace ) ) && - ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) { - eventType.splice( j--, 1 ); - - if ( handleObj.selector ) { - eventType.delegateCount--; - } - if ( special.remove ) { - special.remove.call( elem, handleObj ); - } + // Remove matching events + for ( j = 0; j < eventType.length; j++ ) { + handleObj = eventType[ j ]; + + if ( origType === handleObj.origType && + ( !handler || handler.guid === handleObj.guid ) && + ( !namespaces || namespaces.test( handleObj.namespace ) ) && + ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) { + eventType.splice( j--, 1 ); + + if ( handleObj.selector ) { + eventType.delegateCount--; + } + if ( special.remove ) { + special.remove.call( elem, handleObj ); } } - } else { - // Removing all events - eventType.length = 0; } // Remove generic event handler if we removed something and no more handlers exist |