@cjser/domify
v3.0.0-cjser.2
Published
Turn a HTML string into DOM elements, cross-platform
Maintainers
Readme
domify
Turn a HTML string into DOM elements, cross-platform
Usage
Works out of the box in the browser:
import domify from 'domify';
document.addEventListener('DOMContentLoaded', () => {
const element = domify('<p>Hello <em>there</em></p>');
document.body.appendChild(element);
});You can also run it in Node.js and other non-browser environments by passing a custom implementation of document:
import {JSDOM} from 'jsdom';
const jsdom = new JSDOM();
domify('<p>Hello <em>there</em></p>', jsdom.window.document);Note: For browser-only use, prefer DOMParser.parseFromString().
cjser
This package is a CommonJS-compatible build generated by cjser for projects that still need require() support. The source version matches the original npm package version, with a cjser prerelease suffix for this generated build.
Original repository: https://github.com/sindresorhus/domify
