Browse Source

Fix linting warnings.

pull/73/head
Guillaume Martigny 6 years ago
parent
commit
1f5c9cf901
  1. 23
      src/index.js

23
src/index.js

@ -13,28 +13,27 @@ const defaultJsdomConfig = {
// IIFE executed on import to return an array of global Node.js properties that
// conflict with global browser properties.
const protectedproperties = (() => Object
.getOwnPropertyNames(new Window(defaultJsdomConfig))
.filter(prop => typeof global[prop] !== 'undefined')
.getOwnPropertyNames(new Window(defaultJsdomConfig))
.filter(prop => typeof global[prop] !== 'undefined')
)();
// Sets up global browser environment
const browserEnv = function () {
// Extract options from args
const args = Array.from(arguments);
const browserEnv = function (...args) {
// Extract options from args
const properties = args.filter(arg => Array.isArray(arg))[0];
const userJsdomConfig = args.filter(arg => !Array.isArray(arg))[0];
// Create window object
// Create window object
const window = new Window(Object.assign({}, userJsdomConfig, defaultJsdomConfig));
// Get all global browser properties
// Get all global browser properties
Object.getOwnPropertyNames(window)
// Remove protected properties
.filter(prop => protectedproperties.indexOf(prop) === -1)
// Remove protected properties
.filter(prop => !protectedproperties.includes(prop))
// If we're only applying specific required properties remove everything else
.filter(prop => !(properties && properties.indexOf(prop) === -1))
// 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 => {
@ -44,7 +43,7 @@ const browserEnv = function () {
});
});
// Return reference to original window object
// Return reference to original window object
return window;
};

Loading…
Cancel
Save