get-dom-document
Get a [DOM document](https://developer.mozilla.org/en-US/docs/Web/API/Document) in both Node.js and the browser environment.
Last updated 4 years ago by ocavue .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install get-dom-document 
SYNC missed versions from official npm registry.

get-dom-document

Get a DOM document in both Node.js and the browser environment.

getDomDocument will firstly try to get the DOM document from the global document object. If it is not available, it will try to create a new DOM document using jsdom in Node.js environment. If jsdom is not available or it's not running in Node.js environment, it will return null.

This package use the browser field in package.json and conditional exports to provide different implementations for Node.js and the browser environment.

Install

npm install get-dom-document

Usage

CommonJS:

const { getDomDocument } = require("get-dom-document");

const document = getDomDocument();

ES module:

import { getDomDocument } from "get-dom-document";

const document = getDomDocument();

Current Tags

  • 0.1.3                                ...           latest (4 years ago)

4 Versions

  • 0.1.3                                ...           4 years ago
  • 0.1.2                                ...           4 years ago
  • 0.1.1                                ...           4 years ago
  • 0.1.0                                ...           4 years ago
Maintainers (1)
Downloads
Total 20
Today 0
This Week 0
This Month 11
Last Day 0
Last Week 3
Last Month 8
Dependencies (0)
None
Dev Dependencies (1)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE