diff --git a/src/Global.js b/src/Global.js index 3877c440..d9d1e984 100644 --- a/src/Global.js +++ b/src/Global.js @@ -135,6 +135,22 @@ var Kinetic = {}; } } }; + + // bind() shim for older browsers + if (!Function.prototype.bind) { + Function.prototype.bind = function (oThis) { + 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; + }; + } })(); // Uses Node, AMD or browser globals to create a module.