Skip to content
Permalink
Browse files

Fix for #186 and for jQuery.event.fix

  • Loading branch information
brandonaaron committed Nov 2, 2006
1 parent 40b55ad commit ddd110c9e583fb43257ae1b9b06223bdc7e21f31
Showing with 16 additions and 10 deletions.
  1. +16 −10 src/jquery/jquery.js
@@ -2271,7 +2271,7 @@ jQuery.extend({
handle: function(event) {
if ( typeof jQuery == "undefined" ) return false;

event = event || jQuery.event.fix( window.event );
event = jQuery.event.fix( event || window.event || {} ); // Empty object is for triggered events with no data

// If no correct event was found, fail
if ( !event ) return false;
@@ -2291,33 +2291,39 @@ jQuery.extend({
}
}

// Clean up added properties in IE to prevent memory leak
if (jQuery.browser.msie) event.target = event.preventDefault = event.stopPropagation = null;

return returnValue;
},

fix: function(event) {
// check IE
if(jQuery.browser.msie) {
// get real event from window.event
event = window.event;
// fix target property
event.target = event.srcElement;

// check safari and if target is a textnode
} else if(jQuery.browser.safari && event.target.nodeType == 3) {
// target is readonly, clone the event object
event = jQuery.extend({}, event);
// get parentnode from textnode
event.target = event.target.parentNode;
}

// fix preventDefault and stopPropagation
event.preventDefault = function() {
this.returnValue = false;
};
event.stopPropagation = function() {
this.cancelBubble = true;
};
if (!event.preventDefault)
event.preventDefault = function() {
this.returnValue = false;
};

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

return event;
}

}
});

0 comments on commit ddd110c

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