Turn a HTML string into DOM elements, cross-platform
npm install domify> Turn a HTML string into DOM elements, cross-platform
Works out of the box in the browser:
``js
import domify from 'domify';
document.addEventListener('DOMContentLoaded', () => {
const element = domify('
Hello there
');You can also run it in Node.js and other non-browser environments by passing a custom implementation of
document:`js
import {JSDOM} from 'jsdom';const jsdom = new JSDOM();
domify('
Hello there
', jsdom.window.document);
`DOMParser.parseFromString()`.