Cannot assign to read only property 'product' of object '#<WorkerNavi…
Summary: When running in strict mode we run into the following error: “Cannot assign to read only property 'product' of object '#<WorkerNavigator>’” Moreover navigator.product = ‘ReactNative’; didn’t actually change the product value. Without strict mode this was silently ignored. By using our defineProperty function we are able to run in strict mode and now navigator.product is really ReactNative. See https://github.com/facebook/react-native/issues/10881 for more information --------------- Long story short - if we run in strict mode, the current code throws an error : `Cannot assign to read only property 'product' of object '#<WorkerNavigator>' initializeCore.js` (the current version of initializeCore.js doesn't have 'use strict'; on top, but if you are unfortunate enough to have a babel module that ads this for you, you are guaranteed to run into this. Moreover our contributing guidelines say that we should have 'use strict'; https://github.com/facebook/react-native/blob/master/CONTRIB Closes https://github.com/facebook/react-native/pull/11057 Differential Revision: D4219958 Pulled By: javache fbshipit-source-id: 35568b2ce4b87fff1aa8248f067d49e5f9f9e9a2
This commit is contained in:
parent
3f50a887d9
commit
ad36c1af71
|
@ -27,6 +27,7 @@
|
|||
* 2. Bridged modules.
|
||||
*
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
if (global.GLOBAL === undefined) {
|
||||
global.GLOBAL = global;
|
||||
|
@ -178,7 +179,9 @@ let navigator = global.navigator;
|
|||
if (navigator === undefined) {
|
||||
global.navigator = navigator = {};
|
||||
}
|
||||
navigator.product = 'ReactNative';
|
||||
|
||||
// see https://github.com/facebook/react-native/issues/10881
|
||||
defineProperty(navigator, 'product', () => 'ReactNative', true);
|
||||
defineProperty(navigator, 'geolocation', () => require('Geolocation'));
|
||||
|
||||
// Set up collections
|
||||
|
|
Loading…
Reference in New Issue