Skip to content
Permalink
Browse files

Prevent a single event object from being fixed more than once

  • Loading branch information
brandonaaron committed Apr 27, 2008
1 parent 77bb2c5 commit b84b997ea4be31dd1fdcc63136811dcd324dec68
Showing with 7 additions and 1 deletion.
  1. +7 −1 src/event.js
@@ -268,17 +268,23 @@ jQuery.event = {
// Clean up added properties in IE to prevent memory leak
if (jQuery.browser.msie)
event.target = event.preventDefault = event.stopPropagation =
event.handler = event.data = null;
event.handler = event.data = event[expando] = null;

return val;
},

fix: function(event) {
if ( event[expando] == true )
return event;

// store a copy of the original event object
// and clone to set read-only properties
var originalEvent = event;
event = jQuery.extend({}, originalEvent);

// Mark it as fixed
event[expando] = true;

// add preventDefault and stopPropagation since
// they will not work on the clone
event.preventDefault = function() {

0 comments on commit b84b997

Please sign in to comment.
You can’t perform that action at this time.