JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 146979
  • Score
    100M100P100Q158060F

turn HTML into DOM elements

Package Exports

  • domify

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (domify) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

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