diff --git a/lib/client/polyfill.js b/lib/client/polyfill.js index f19949a9..9807043a 100644 --- a/lib/client/polyfill.js +++ b/lib/client/polyfill.js @@ -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,