fix(polyfill) bind

This commit is contained in:
coderaiser 2014-01-31 11:36:02 -05:00
parent 53450a5b31
commit 974cbb6b1b

View file

@ -30,13 +30,22 @@ var Util, DOM, jQuery;
}
if (!Function.bind)
Function.prototype.bind = function(context) {
var _this = this;
Function.prototype.bind = function (context) {
var aArgs = Util.slice(arguments, 1),
fToBind = this,
NOP = function () {},
fBound = function () {
var arr = Util.slice(arguments);
args = aArgs.concat(arr);
return fToBind.apply(context, args);
};
NOP.prototype = this.prototype;
fBound.prototype = new NOP();
return function() {
return _this.apply(context, arguments);
};
};
return fBound;
};
/*
* typeof callback === "function" should not be used,