From: Jörn Zaefferer Date: Thu, 30 Nov 2006 20:39:33 +0000 (+0000) Subject: Fix for event fix: Don't overwrite event.target if there is no srcElement; calculate... X-Git-Tag: 1.0.4~20 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=d98283a3a39b2fd4d2b0986c34c92f8c7b3c4e54;p=jquery.git Fix for event fix: Don't overwrite event.target if there is no srcElement; calculate pageX/Y (tested with tooltip plugin) --- diff --git a/src/jquery/jquery.js b/src/jquery/jquery.js index 689784a56..4164f6390 100644 --- a/src/jquery/jquery.js +++ b/src/jquery/jquery.js @@ -1959,9 +1959,16 @@ jQuery.extend({ fix: function(event) { // check IE if(jQuery.browser.msie) { - // fix target property - event.target = event.srcElement; - + // fix target property, if available + // check prevents overwriting of fake target coming from trigger + if(event.srcElement) + event.target = event.srcElement; + + // calculate pageX/Y + var e = document.documentElement, b = document.body; + event.pageX = event.clientX + (e.scrollLeft || b.scrollLeft); + event.pageY = event.clientY + (e.scrollTop || b.scrollTop); + // check safari and if target is a textnode } else if(jQuery.browser.safari && event.target.nodeType == 3) { // target is readonly, clone the event object @@ -1980,7 +1987,7 @@ jQuery.extend({ event.stopPropagation = function() { this.cancelBubble = true; }; - + return event; } }