From 44d0802700b92d3623bfdd9976099a974d8050c8 Mon Sep 17 00:00:00 2001 From: Tim de Koning Date: Wed, 27 Jun 2012 18:30:43 +0200 Subject: [PATCH] We should use feature detection. Thanks @brendandahl --- web/compatibility.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/web/compatibility.js b/web/compatibility.js index 540dff0b1..56a0ba43a 100644 --- a/web/compatibility.js +++ b/web/compatibility.js @@ -79,9 +79,16 @@ // 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];