1 // Fix old versions of Webkit (such as ones used on iOS < 6 or PhantomJS <= 1.7)
2 // which does not have Function.prototype.bind function
5 // https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Function/bind#Compatibility
6 if (!Function.prototype.bind) {
7 Function.prototype.bind = function (oThis) {
8 if (typeof this !== "function") {
9 // closest thing possible to the ECMAScript 5 internal IsCallable function
10 throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");
13 var aArgs = Array.prototype.slice.call(arguments, 1),
15 fNOP = function () {},
16 fBound = function () {
17 return fToBind.apply(this instanceof fNOP && oThis
20 aArgs.concat(Array.prototype.slice.call(arguments)));
23 fNOP.prototype = this.prototype;
24 fBound.prototype = new fNOP();