diff options
author | Thomas Mueller <thomas.mueller@tmit.eu> | 2013-02-14 12:16:51 +0100 |
---|---|---|
committer | Thomas Mueller <thomas.mueller@tmit.eu> | 2013-02-14 12:20:04 +0100 |
commit | 8877087b5716fde078bab4d303240498f02dd48b (patch) | |
tree | ec897d2aae2804e41929cd342452959b6ba28255 /core/js/compatibility.js | |
parent | a03d70209fabbb3d2ae7137a6edde1f0712cd9e1 (diff) | |
download | nextcloud-server-8877087b5716fde078bab4d303240498f02dd48b.tar.gz nextcloud-server-8877087b5716fde078bab4d303240498f02dd48b.zip |
adding a compatibility.js as a single source to define all fallback function declarations
Diffstat (limited to 'core/js/compatibility.js')
-rw-r--r-- | core/js/compatibility.js | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/core/js/compatibility.js b/core/js/compatibility.js new file mode 100644 index 00000000000..3e9178f3200 --- /dev/null +++ b/core/js/compatibility.js @@ -0,0 +1,25 @@ + +//https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Function/bind +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; + }; +} |