fix IE native mothods are not functions, and preventDefault

This commit is contained in:
unknown 2010-07-27 16:53:23 -07:00
parent 2a30a02f01
commit 6bd8006edc
3 changed files with 20 additions and 16 deletions

View file

@ -293,13 +293,18 @@ function escapeAttr(html) {
function bind(_this, _function) {
var curryArgs = slice.call(arguments, 2, arguments.length);
return curryArgs.length == 0 ?
function() {
return _function.apply(_this, arguments);
} :
function() {
return _function.apply(_this, curryArgs.concat(slice.call(arguments, 0, arguments.length)));
};
if (typeof _function == 'function') {
return curryArgs.length == 0 ?
function() {
return _function.apply(_this, arguments);
} :
function() {
return _function.apply(_this, curryArgs.concat(slice.call(arguments, 0, arguments.length)));
}
} else {
// in IE, native methonds ore not functions and so they can not be bound (but they don't need to be)
return function(a, b, c, d, e){ return _function(a, b, c, d, e); };
}
}
function outerHTML(node) {

View file

@ -599,14 +599,11 @@ Parser.prototype = {
for ( var i = 0; i < argsFn.length; i++) {
args.push(argsFn[i](self));
}
var fnPtr = fn(self);
if (typeof fnPtr === 'function') {
return fnPtr.apply(self, args);
} else if (fnPtr === undefined) {
return fnPtr;
} else {
throw "Expression '" + fn.isAssignable + "' is not a function.";
}
var fnPtr = fn(self) || noop;
// IE stupidity!
return fnPtr.apply ?
fnPtr.apply(self, args) :
fnPtr(args[0], args[1], args[2], args[3], args[4]);
};
},

View file

@ -105,7 +105,9 @@ JQLite.prototype = {
if (!eventHandler) {
bind[type] = eventHandler = function(event) {
if (!event.preventDefault) {
event.returnValue = false;
event.preventDefault = function(){
event.returnValue = false;
}
}
foreach(eventHandler.fns, function(fn){
fn.call(self, event);