1.2.0 • Published 3 years ago

dom-serialization v1.2.0

Weekly downloads
2
License
MIT
Repository
github
Last release
3 years ago

DOM Serialization

Serialize the DOM

Q. Why don't you use innerHTML?

: when you use innerHTML you lose tree structure if there are adjacent text nodes.

            span
          /       \
  text node       text node

dom-serialization serialize the DOM with keeping tree structure. So you can keep tree structure when you deserialize from serialized string.

Getting started

npm install dom-serialization
import { serialize, deserialize } from 'dom-serialization';

const dom = document.createElement('div');
dom.appendChild(document.createTextNode('hello'));
dom.appendChild(document.createTextNode('world'));

const code = serialize(dom);
console.log(deserialize(code));
1.2.0

3 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago