0.1.3 • Published 2 years ago

get-dom-document v0.1.3

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

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