Browse Source

Update window to version 4.2.6 (#75)

* Require window@4.2.6

* Set global properties as getters

Some properties will throw an error when accessed in certain conditions. We don't want to throw these errors, by accessing them when we setup the environemnt. Instead we should create getters for all window properties so they can throw the appropriate errors when accessed by user code.

* Update expectedProperties.json for window@4.2.6
pull/73/head
Luke Childs 6 years ago
committed by Guillaume Martigny
parent
commit
fd6d0b9760
  1. 11
      src/index.js

11
src/index.js

@ -35,10 +35,13 @@ const browserEnv = function (...args) {
// If we're only applying specific required properties remove everything else
.filter(prop => !properties || properties.includes(prop))
// Copy what's left to the Node.js global scope
.forEach(prop => {
global[prop] = window[prop];
});
// Copy what's left to the Node.js global scope
.forEach(prop => {
Object.defineProperty(global, prop, {
configurable: true,
get: () => window[prop]
});
});
// Return reference to original window object
return window;

Loading…
Cancel
Save