aboutsummaryrefslogtreecommitdiffstats
path: root/src/event.js
diff options
context:
space:
mode:
authorOleg <markelog@gmail.com>2012-04-04 21:17:01 -0400
committerDave Methvin <dave.methvin@gmail.com>2012-04-04 21:38:46 -0400
commit203a168980ece60213c87a10ac0ad294783d5563 (patch)
treed4bd8461d3454731b47179d60cff10eaad03558d /src/event.js
parent41056ab1957b44bf5be2184f5c566121a985b38a (diff)
downloadjquery-203a168980ece60213c87a10ac0ad294783d5563.tar.gz
jquery-203a168980ece60213c87a10ac0ad294783d5563.zip
Fix #8545. Plug event handling memory leak in oldIE.
Diffstat (limited to 'src/event.js')
-rw-r--r--src/event.js20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/event.js b/src/event.js
index 621464fdd..ad3f3e750 100644
--- a/src/event.js
+++ b/src/event.js
@@ -154,7 +154,7 @@ jQuery.event = {
var elemData = jQuery.hasData( elem ) && jQuery._data( elem ),
t, tns, type, origType, namespaces, origCount,
- j, events, special, handle, eventType, handleObj;
+ j, events, special, eventType, handleObj;
if ( !elemData || !(events = elemData.events) ) {
return;
@@ -213,14 +213,11 @@ jQuery.event = {
// Remove the expando if it's no longer used
if ( jQuery.isEmptyObject( events ) ) {
- handle = elemData.handle;
- if ( handle ) {
- handle.elem = null;
- }
+ delete elemData.handle;
// removeData also checks for emptiness and clears the expando if empty
// so use it instead of delete
- jQuery.removeData( elem, [ "events", "handle" ], true );
+ jQuery.removeData( elem, "events", true );
}
},
@@ -636,8 +633,17 @@ jQuery.removeEvent = document.removeEventListener ?
}
} :
function( elem, type, handle ) {
+ var name = "on" + type;
+
if ( elem.detachEvent ) {
- elem.detachEvent( "on" + type, handle );
+
+ // #8545, #7054, preventing memory leaks for custom events in IE6-8 –
+ // detachEvent needed property on element, by name of that event, to properly expose it to GC
+ if ( typeof elem[ name ] === "undefined" ) {
+ elem[ name ] = null;
+ }
+
+ elem.detachEvent( name, handle );
}
};