From 268003f241ea3f6c07421285b8e759721963989c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Mon, 27 May 2013 15:25:40 -0700 Subject: [PATCH] Update to latest straps.js Enabling paper.install(window) again. --- lib/straps.js | 49 ++++++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/lib/straps.js b/lib/straps.js index 30bc0fed..daccb359 100755 --- a/lib/straps.js +++ b/lib/straps.js @@ -45,29 +45,8 @@ var Base = new function() { // support Firefox 3.5 & 3.6, and this hack works there: return { __proto__: proto }; }, - _define = Object.defineProperty || function(obj, name, desc) { - // Emulate Object.defineProperty for outdated browsers - if ((desc.get || desc.set) && obj.__defineGetter__) { - if (desc.get) - obj.__defineGetter__(name, desc.get); - if (desc.set) - obj.__defineSetter__(name, desc.set); - } else { - obj[name] = desc.value; - } - return obj; - }, - _describe = Object.getOwnPropertyDescriptor || function(obj, name) { - // Emulate Object.getOwnPropertyDescriptor for outdated browsers - var get = obj.__lookupGetter__ && obj.__lookupGetter__(name); - return get - ? { get: get, set: obj.__lookupSetter__(name), - enumerable: true, configurable: true } - : obj.hasOwnProperty(name) - ? { value: obj[name], enumerable: true, - configurable: true, writable: true } - : null; - }; + _define = Object.defineProperty, + _describe = Object.getOwnPropertyDescriptor; function define(obj, name, desc) { try { @@ -76,12 +55,36 @@ var Base = new function() { delete obj[name]; return _define(obj, name, desc); } catch (e) {} + // Emulate Object.defineProperty for outdated browsers. + // NOTE: We're also falling back on this scenario currently when the + // above trigggers an exception, e.g. when using Base.define on the + // window object. + if ((desc.get || desc.set) && obj.__defineGetter__) { + if (desc.get) + obj.__defineGetter__(name, desc.get); + if (desc.set) + obj.__defineSetter__(name, desc.set); + } else { + obj[name] = desc.value; + } + return obj; } function describe(obj, name) { try { return _describe(obj, name); } catch (e) {} + // Emulate Object.getOwnPropertyDescriptor for outdated browsers + // NOTE: We're also falling back on this scenario currently when the + // above trigggers an exception. + var get = obj.__lookupGetter__ && obj.__lookupGetter__(name); + return get + ? { get: get, set: obj.__lookupSetter__(name), + enumerable: true, configurable: true } + : obj.hasOwnProperty(name) + ? { value: obj[name], writable: true , + enumerable: true, configurable: true } + : null; } /**