Improved event fixing, using less browser and more object detection
This commit is contained in:
parent
dd27ea5830
commit
0d149e52e6
2 changed files with 14 additions and 15 deletions
|
@ -7,6 +7,7 @@ New and Noteworthy
|
||||||
- Fixed synchronous requests
|
- Fixed synchronous requests
|
||||||
- $.get, $.getIfModified, $.post, $.getScript and $.getJSON now all pass through the XMLHttpRequest as returned by $.ajax
|
- $.get, $.getIfModified, $.post, $.getScript and $.getJSON now all pass through the XMLHttpRequest as returned by $.ajax
|
||||||
- Improved AJAX docs (eg. more examples for $.ajax
|
- Improved AJAX docs (eg. more examples for $.ajax
|
||||||
|
- Improved event fixing, using less browser and more object detection
|
||||||
|
|
||||||
1.0.4
|
1.0.4
|
||||||
-----
|
-----
|
||||||
|
|
28
src/jquery/jquery.js
vendored
28
src/jquery/jquery.js
vendored
|
@ -1960,9 +1960,6 @@ jQuery.extend({
|
||||||
|
|
||||||
event = jQuery.event.fix( event || window.event || {} ); // Empty object is for triggered events with no data
|
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;
|
|
||||||
|
|
||||||
var returnValue = true;
|
var returnValue = true;
|
||||||
|
|
||||||
var c = this.events[event.type];
|
var c = this.events[event.type];
|
||||||
|
@ -1985,20 +1982,19 @@ jQuery.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
fix: function(event) {
|
fix: function(event) {
|
||||||
// check IE
|
// fix target property, if available
|
||||||
if(jQuery.browser.msie) {
|
if(event.srcElement)
|
||||||
// fix target property, if available
|
event.target = event.srcElement;
|
||||||
// check prevents overwriting of fake target coming from trigger
|
|
||||||
if(event.srcElement)
|
// calculate pageX/Y if missing
|
||||||
event.target = event.srcElement;
|
if(typeof event.pageX == "undefined") {
|
||||||
|
|
||||||
// calculate pageX/Y
|
|
||||||
var e = document.documentElement, b = document.body;
|
var e = document.documentElement, b = document.body;
|
||||||
event.pageX = event.clientX + (e.scrollLeft || b.scrollLeft);
|
event.pageX = event.clientX + (e.scrollLeft || b.scrollLeft);
|
||||||
event.pageY = event.clientY + (e.scrollTop || b.scrollTop);
|
event.pageY = event.clientY + (e.scrollTop || b.scrollTop);
|
||||||
|
}
|
||||||
|
|
||||||
// check safari and if target is a textnode
|
// check if target is a textnode (only for safari)
|
||||||
} else if(jQuery.browser.safari && event.target.nodeType == 3) {
|
if(jQuery.browser.safari && event.target.nodeType == 3) {
|
||||||
// target is readonly, clone the event object
|
// target is readonly, clone the event object
|
||||||
event = jQuery.extend({}, event);
|
event = jQuery.extend({}, event);
|
||||||
// get parentnode from textnode
|
// get parentnode from textnode
|
||||||
|
@ -2006,15 +2002,17 @@ jQuery.extend({
|
||||||
}
|
}
|
||||||
|
|
||||||
// fix preventDefault and stopPropagation
|
// fix preventDefault and stopPropagation
|
||||||
if (!event.preventDefault)
|
if (!event.preventDefault) {
|
||||||
event.preventDefault = function() {
|
event.preventDefault = function() {
|
||||||
this.returnValue = false;
|
this.returnValue = false;
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
if (!event.stopPropagation)
|
if (!event.stopPropagation) {
|
||||||
event.stopPropagation = function() {
|
event.stopPropagation = function() {
|
||||||
this.cancelBubble = true;
|
this.cancelBubble = true;
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue