Skip to content

Instantly share code, notes, and snippets.

@acdha
Created February 4, 2014 19:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save acdha/8810743 to your computer and use it in GitHub Desktop.
Save acdha/8810743 to your computer and use it in GitHub Desktop.
Partial Intl.js patch for IE8 support
diff --git a/public_website/static/external/intl/Intl.js b/public_website/static/external/intl/Intl.js
index a86c1f3..65befab 100644
--- a/public_website/static/external/intl/Intl.js
+++ b/public_website/static/external/intl/Intl.js
@@ -25,23 +25,30 @@
}
})(typeof global !== 'undefined' ? global : this, function() {
"use strict";
-var
- Intl = {},
// Need a workaround for getters in ES3
- es3 = !Object.defineProperty && Object.prototype.__defineGetter__,
+ var es3 = !Object.defineProperty && Object.prototype.__defineGetter__,
+ defineProperty;
+
+ // Naive defineProperty for compatibility
+ try {
+ Object.defineProperty({}, '__testDefineProperty', {});
+ defineProperty = Object.defineProperty;
+ } catch (exc) {
+ defineProperty = function (obj, name, desc) {
+ if (desc.get && obj.__defineGetter__) {
+ obj.__defineGetter__(name, desc.get);
+ } else if (hop.call(desc, 'value')) {
+ obj[name] = desc.value;
+ }
+ };
+ }
+
+ var Intl = {},
// We use this a lot (and need it for proto-less objects)
hop = Object.prototype.hasOwnProperty,
- // Naive defineProperty for compatibility
- defineProperty = Object.defineProperty || function (obj, name, desc) {
- if (desc.get && obj.__defineGetter__)
- obj.__defineGetter__(name, desc.get);
- else if (hop.call(desc, 'value'))
- obj[name] = desc.value;
- },
-
// Array.prototype.indexOf, as good as we need it to be
arrIndexOf = Array.prototype.indexOf || function (search) {
/*jshint validthis:true */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment