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

@newhippo/get-dom

Package Overview
Dependencies
Maintainers
4
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@newhippo/get-dom

Return a Window, Document, or DOMImplementation instance in both Node and the browser

  • 1.0.3
  • latest
  • npm
  • Socket score

Version published
Maintainers
4
Created
Source

get-dom

CircleCI

This is a very simple module. Use it whenever you need to have access to either a Document or a DOMImplementation instance in Node or the browser transparently.

When running in Node, this will use jsdom to provide you with the right objects. While jsdom works in the browser, it's a pretty big dependency to have and you already have a DOM there. So when loaded in a browser this module does not at all depend on jsdom but rather returns the current document and its document.implementation. (If you want a new instance, just use the DOMImplementation to create one).

NOTE: This only works with bundlers that respect the browser field in package.json (Browserify does, I guess the other big ones do too).

The major version number for this module now tracks that of jsdom.

Installation

npm install get-dom

API

import dom from 'get-dom';
let doc = dom.document();
let impl = dom.implementation();
let wind = dom.window();

Or for those of you who like your JS retro:

var dom = require('get-dom');
var doc = dom.document();
var impl = dom.implementation();
var wind = dom.window();

You can look under example-browser to see how this works in the browser, once browserified.

Keywords

FAQs

Package last updated on 07 Feb 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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