enable-window-document
Advanced tools
Comparing version 1.15.0 to 1.17.0
let JSDOM = require('jsdom'), | ||
DOM = new JSDOM.JSDOM(`<html><body></body></html>`, { | ||
url: 'https://localhost' | ||
url: 'https://localhost', | ||
resources: 'usable', | ||
runScripts: 'dangerously' | ||
}); | ||
@@ -5,0 +7,0 @@ |
{ | ||
"name": "enable-window-document", | ||
"version": "1.15.0", | ||
"version": "1.17.0", | ||
"description": "Enables \"window\" and \"document\" globals so browser code does not throw errors in Node. Built with JSDOM.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -35,10 +35,16 @@ # Enable `window` and `document` | ||
## Implementation | ||
This package simply creates a blank JSDOM with four lines of code, and stores the global `window` and `document` variables, which point to the empty DOM: | ||
This package simply creates a blank JSDOM with a few lines of code, and stores the global `window` and `document` variables, which point to the empty DOM: | ||
``` | ||
let JSDOM = require('jsdom'), | ||
DOM = new JSDOM.JSDOM(`<html><body></body></html>`); | ||
DOM = new JSDOM.JSDOM(`<html><body></body></html>`, { | ||
url: 'https://localhost', | ||
resources: 'usable', | ||
runScripts: 'dangerously' | ||
}); | ||
global.window = DOM.window, | ||
global.document = window.document; | ||
``` | ||
``` | ||
The `url` param is set for compatibility reasons related to `localStorage`, and `resources` and `runScripts` are set by default so that external scripts work as expected. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
7005
7
49