Socket
Socket
Sign inDemoInstall

domify

Package Overview
Dependencies
0
Maintainers
28
Versions
16
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    domify

Turn a HTML string into DOM elements, cross-platform


Version published
Weekly downloads
116K
decreased by-4.02%
Maintainers
28
Install size
4.79 kB
Created
Weekly downloads
 

Readme

Source

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

Keywords

FAQs

Last updated on 17 Nov 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc