properly handle event's stopPropagation() and preventDefault() method in IE

This commit is contained in:
Igor Minar 2010-10-01 07:33:34 +08:00 committed by Misko Hevery
parent eb8d46d380
commit 0af763dcec

View file

@ -99,9 +99,14 @@ JQLite.prototype = {
bind[type] = eventHandler = function(event) { bind[type] = eventHandler = function(event) {
if (!event.preventDefault) { if (!event.preventDefault) {
event.preventDefault = function(){ event.preventDefault = function(){
event.returnValue = false; event.returnValue = false; //ie
}; };
} }
if (!event.stopPropagation) {
event.stopPropagation = function() {
event.cancelBubble = true; //ie
}
}
foreach(eventHandler.fns, function(fn){ foreach(eventHandler.fns, function(fn){
fn.call(self, event); fn.call(self, event);
}); });
@ -194,9 +199,8 @@ JQLite.prototype = {
} else if (isDefined(value)) { } else if (isDefined(value)) {
e.setAttribute(name, value); e.setAttribute(name, value);
} else { } else {
var attributes = e.attributes, // the extra argument is to get the right thing for a.href in IE, see jQuery code
item = attributes ? attributes.getNamedItem(name) : _undefined; return e.getAttribute(name, 2);
return item && item.specified ? item.value : _undefined;
} }
}, },