From 5d170a67e0bb24a9b36f3067e64132a624a2b55f Mon Sep 17 00:00:00 2001
From: Shane Tomlinson <stomlinson@mozilla.com>
Date: Thu, 11 Aug 2011 12:02:04 -0700
Subject: [PATCH] Adding Function.prototype.bind for browsers that do not
 support it.

---
 browserid/static/dialog/dialog.js             |  1 +
 .../dialog/resources/browserid-extensions.js  | 23 +++++++++++++++++++
 2 files changed, 24 insertions(+)
 create mode 100644 browserid/static/dialog/resources/browserid-extensions.js

diff --git a/browserid/static/dialog/dialog.js b/browserid/static/dialog/dialog.js
index ac0019d15..238dcc7cb 100644
--- a/browserid/static/dialog/dialog.js
+++ b/browserid/static/dialog/dialog.js
@@ -49,6 +49,7 @@ steal.plugins(
                'crypto-api',
                'channel',
                'storage',
+               'browserid-extensions',
                'browserid-network',
                'browserid-errors',
                'browserid-wait')					// 3rd party script's (like jQueryUI), in resources folder
diff --git a/browserid/static/dialog/resources/browserid-extensions.js b/browserid/static/dialog/resources/browserid-extensions.js
new file mode 100644
index 000000000..baf2bdc1e
--- /dev/null
+++ b/browserid/static/dialog/resources/browserid-extensions.js
@@ -0,0 +1,23 @@
+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 fBound is not callable");
+
+    var aArgs = Array.prototype.slice.call(arguments, 1), 
+    fToBind = this, 
+    fNOP = function () {},
+    fBound = function () {
+      return fToBind.apply(this instanceof fNOP ? this : oThis || window, aArgs.concat(Array.prototype.slice.call(arguments)));    
+    };
+
+    fNOP.prototype = this.prototype;
+    fBound.prototype = new fNOP();
+
+    return fBound;
+
+  };
+
+}
+
-- 
GitLab