|
@ -18,9 +18,8 @@ const protectedproperties = (() => Object |
|
|
)(); |
|
|
)(); |
|
|
|
|
|
|
|
|
// Sets up global browser environment
|
|
|
// Sets up global browser environment
|
|
|
const browserEnv = function () { |
|
|
const browserEnv = function (...args) { |
|
|
// Extract options from args
|
|
|
// Extract options from args
|
|
|
const args = Array.from(arguments); |
|
|
|
|
|
const properties = args.filter(arg => Array.isArray(arg))[0]; |
|
|
const properties = args.filter(arg => Array.isArray(arg))[0]; |
|
|
const userJsdomConfig = args.filter(arg => !Array.isArray(arg))[0]; |
|
|
const userJsdomConfig = args.filter(arg => !Array.isArray(arg))[0]; |
|
|
|
|
|
|
|
@ -31,10 +30,10 @@ const browserEnv = function () { |
|
|
Object.getOwnPropertyNames(window) |
|
|
Object.getOwnPropertyNames(window) |
|
|
|
|
|
|
|
|
// Remove protected properties
|
|
|
// Remove protected properties
|
|
|
.filter(prop => protectedproperties.indexOf(prop) === -1) |
|
|
.filter(prop => !protectedproperties.includes(prop)) |
|
|
|
|
|
|
|
|
// If we're only applying specific required properties remove everything else
|
|
|
// If we're only applying specific required properties remove everything else
|
|
|
.filter(prop => !(properties && properties.indexOf(prop) === -1)) |
|
|
.filter(prop => !properties || properties.includes(prop)) |
|
|
|
|
|
|
|
|
// Copy what's left to the Node.js global scope
|
|
|
// Copy what's left to the Node.js global scope
|
|
|
.forEach(prop => { |
|
|
.forEach(prop => { |
|
|