mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-28 18:23:35 +00:00
fix(polyfill) bind
This commit is contained in:
parent
53450a5b31
commit
974cbb6b1b
1 changed files with 15 additions and 6 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue