aboutsummaryrefslogtreecommitdiffstats
path: root/core/js/compatibility.js
diff options
context:
space:
mode:
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;
+ };
+}