summaryrefslogtreecommitdiffstats
path: root/core/js/compatibility.js
diff options
context:
space:
mode:
authorThomas Mueller <thomas.mueller@tmit.eu>2013-02-14 12:16:51 +0100
committerThomas Mueller <thomas.mueller@tmit.eu>2013-02-14 12:20:04 +0100
commit8877087b5716fde078bab4d303240498f02dd48b (patch)
treeec897d2aae2804e41929cd342452959b6ba28255 /core/js/compatibility.js
parenta03d70209fabbb3d2ae7137a6edde1f0712cd9e1 (diff)
downloadnextcloud-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.js25
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;
+ };
+}