0.1.3 • Published 3 years ago
get-dom-document v0.1.3
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-documentUsage
CommonJS:
const { getDomDocument } = require("get-dom-document");
const document = getDomDocument();ES module:
import { getDomDocument } from "get-dom-document";
const document = getDomDocument();