Sha256: 2c6937a3e4e0868307abb0ff9abb683630377c4403de7fb0c143d82828811e3c

Contents?: true

Size: 900 Bytes

Versions: 3

Compression:

Stored size: 900 Bytes

Contents

// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind#Compatibility
if (!Function.prototype.bind) {
  Function.prototype.bind = function (oThis) {
    if (typeof this !== "function") {
      // closest thing possible to the ECMAScript 5 internal IsCallable function
      throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");
    }

    var aArgs = Array.prototype.slice.call(arguments, 1),
        fToBind = this,
        fNOP = function () {},
        fBound = function () {
          return fToBind.apply(this instanceof fNOP && oThis
                                 ? this
                                 : oThis,
                               aArgs.concat(Array.prototype.slice.call(arguments)));
        };

    fNOP.prototype = this.prototype;
    fBound.prototype = new fNOP();

    return fBound;
  };
}

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ie-compat-0.1.2 lib/assets/ie-compat/function_bind.js
ie-compat-0.1.1 lib/assets/ie-compat/function_bind.js
ie-compat-0.1.0 assets/ie-compat/function_bind.js