Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ariperkkio/virtual-dom-nodes

Apply changes to DOM Elements with minimal work
https://github.com/ariperkkio/virtual-dom-nodes

dom dom-manipulation

Last synced: 15 days ago
JSON representation

Apply changes to DOM Elements with minimal work

Awesome Lists containing this project

README

        

# virtual-dom-nodes

[![version](https://img.shields.io/npm/v/virtual-dom-nodes)](https://www.npmjs.com/package/virtual-dom-nodes)

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

## API

### `update`

```ts
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, "

Hello world
");

> element.outerHTML
'

Hello world
'
```

### `htmlToElement`

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

const element = htmlToElement(`


Hello world!

`);

> element instanceof Element
true

> element.outerHTML
'

Hello world!
'
```