13.0.0 • Published 5 years ago

get-dom v13.0.0

Weekly downloads
75
License
Apache-2.0
Repository
github
Last release
5 years ago

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();

Or for those of you who like your JS retro:

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

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

13.0.0

5 years ago

9.0.0

8 years ago

1.2.0

8 years ago

1.1.0

8 years ago

1.0.2

8 years ago

1.0.1

9 years ago

1.0.0

9 years ago