diff --git a/Libraries/JavaScriptAppEngine/Initialization/InitializeJavaScriptAppEngine.js b/Libraries/JavaScriptAppEngine/Initialization/InitializeJavaScriptAppEngine.js index 60b574709..bec2ddfbf 100644 --- a/Libraries/JavaScriptAppEngine/Initialization/InitializeJavaScriptAppEngine.js +++ b/Libraries/JavaScriptAppEngine/Initialization/InitializeJavaScriptAppEngine.js @@ -77,13 +77,16 @@ function defineProperty(object: Object, name: string, newValue: mixed): void { value: object[name], }); } - const {enumerable, writable} = descriptor || {}; - Object.defineProperty(object, name, { - configurable: true, - enumerable: enumerable !== false, - writable: writable !== false, - value: newValue, - }); + + const {enumerable, writable, configurable} = descriptor || {}; + if (!descriptor || configurable) { + Object.defineProperty(object, name, { + configurable: true, + enumerable: enumerable !== false, + writable: writable !== false, + value: newValue, + }); + } } function defineLazyProperty( @@ -98,11 +101,15 @@ function defineLazyProperty( const backupName = `original${name[0].toUpperCase()}${name.substr(1)}`; Object.defineProperty(object, backupName, descriptor); } - defineLazyObjectProperty(object, name, { - get: getNewValue, - enumerable: descriptor ? descriptor.enumerable !== false : true, - writable: descriptor ? descriptor.writable !== false : true, - }); + + const {configurable} = descriptor || {}; + if (!descriptor || configurable) { + defineLazyObjectProperty(object, name, { + get: getNewValue, + enumerable: descriptor ? descriptor.enumerable !== false : true, + writable: descriptor ? descriptor.writable !== false : true, + }); + } } function setUpErrorHandler(): void {