Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Commit

Permalink
fix(jqLite): fix memory leaking in IE8 (remove monkey patched methods…
Browse files Browse the repository at this point in the history
… on Event)

These methods cause IE8 holds the whole jqLite in the memory, even when page is reloaded.
jqLite's cache keeps element's data (event handlers, attached scopes, injector, etc…), so almost all used memory is never released in IE8.

jQuery creates its own Event object (wrapper around native Event) instead.
  • Loading branch information
vojtajina committed Feb 5, 2012
1 parent 6c4f139 commit 3173d86
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/jqLite.js
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,13 @@ forEach({
forEach(eventHandler.fns, function(fn){
fn.call(element, event);
});

// Remove monkey-patched methods (IE),
// as they would cause memory leaks in IE8.
// It shouldn't affect normal browsers, as their native methods are defined on prototype.
delete event.preventDefault
delete event.stopPropagation
delete event.isDefaultPrevented
};
eventHandler.fns = [];
addEventListenerFn(element, type, eventHandler);
Expand Down

0 comments on commit 3173d86

Please sign in to comment.