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 3 years ago by ocavue .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm 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 (3 years ago)

4 Versions

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

Copyright 2013 - present © cnpmjs.org | Home |