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

Commit

Permalink
fix(jqLite): set event's monkey patched methods to null (on IE7)
Browse files Browse the repository at this point in the history
  • Loading branch information
vojtajina committed Feb 24, 2012
1 parent 3171f21 commit 230f29d
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/jqLite.js
Original file line number Diff line number Diff line change
Expand Up @@ -474,11 +474,13 @@ function createEventHandler(element) {
event.returnValue = false; //ie
};
}

if (!event.stopPropagation) {
event.stopPropagation = function() {
event.cancelBubble = true; //ie
};
}

if (!event.target) {
event.target = event.srcElement || document;
}
Expand All @@ -502,10 +504,17 @@ function createEventHandler(element) {

// 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;
if (msie < 8) {
// IE7 does not allow to delete property on native object
event.preventDefault = null;
event.stopPropagation = null;
event.isDefaultPrevented = null;
} else {
// It shouldn't affect normal browsers (native methods are defined on prototype).
delete event.preventDefault;
delete event.stopPropagation;
delete event.isDefaultPrevented;
}
};
eventHandler.fns = [];
return eventHandler;
Expand Down

0 comments on commit 230f29d

Please sign in to comment.