Socket
Book a DemoInstallSign in
Socket

virtual-dom-nodes

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

virtual-dom-nodes

Apply changes to DOM Elements with minimal work.

latest
Source
npmnpm
Version
0.2.2
Version published
Maintainers
1
Created
Source

virtual-dom-nodes

version

Apply changes to DOM Elements with minimal work. Utilizes internal "virtual DOM" to avoid causing expensive and slow DOM manipulations.

API

update

import { update } from 'virtual-dom-nodes';

const element = document.createElement('div');
element.setAttribute('id', 'demo-id');
element.appendChild(document.createTextNode('Hello world'));

// Optimally applies required changes to element
update(element, "<div id='new-id'>Hello world<div>");

> element.outerHTML
'<div id="new-id">Hello world<div>'

htmlToElement

import { htmlToElement } from 'virtual-dom-nodes';

const element = htmlToElement(`
    <div role="status" id="test-id">
        Hello world!
    </div>
`);

> element instanceof Element
true

> element.outerHTML
'<div role="status" id="test-id">Hello world!</div>'

FAQs

Package last updated on 17 Feb 2024

Did you know?

Socket

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