Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

enable-window-document

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

enable-window-document - npm Package Compare versions

Comparing version 1.15.0 to 1.17.0

4

index.js
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.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc