]> git.parisson.com Git - pdf.js.git/commitdiff
We should use feature detection. Thanks @brendandahl
authorTim de Koning <github@kingsquare.nl>
Wed, 27 Jun 2012 16:30:43 +0000 (18:30 +0200)
committerTim de Koning <github@kingsquare.nl>
Wed, 27 Jun 2012 16:30:43 +0000 (18:30 +0200)
web/compatibility.js

index 540dff0b10f3c56de847c9dd110729f9b4c29fb6..56a0ba43acc08f9a7e932eca4fe557fbcba84990 100644 (file)
 
 // Object.defineProperty() ?
 (function checkObjectDefinePropertyCompatibility() {
-  // safari 5 and 6 cannot use this on DOM objects and thus it's unusable,
-  if ((typeof Object.defineProperty !== 'undefined') &&
-    !/Safari/.test(navigator.userAgent)) return;
+  if (typeof Object.defineProperty !== 'undefined') {
+    // Some browsers (e.g. safari) cannot use this on DOM objects
+    var definePropertyPossible = true;
+    try {
+      Object.defineProperty(new Image(), 'id', { value: 'test' });
+    } catch (e) {
+      definePropertyPossible = false;
+    }
+    if (definePropertyPossible) return true;
+  }
 
   Object.defineProperty = function objectDefineProperty(obj, name, def) {
     delete obj[name];