Merge the DOM of 2 elements with the same textContent
npm install zip-text-nodes> Merge the DOM of 2 elements with the same textContent.
Given 2 elements:
``html`
Hello, world!
and:
`html`
Hello, world!
they are merged into:
`html`
Hello, world!
This can be useful when running some transformations on the content of an element and successively merging the results or restoring the original markup.
`js
const base = <>I live in Italy>;
const grammar = highlightVerb(base);
// <>I live in Italy> // e.g. the link was lost
zipTextNodes(base, grammar);
// <>I live in Italy>
// The new em is copied from grammar to base`
Supports overlapping and nested elements.
``
npm install zip-text-nodes
`js`
const zipTextNodes = require('zip-text-nodes');
`js`
import zipTextNodes from 'zip-text-nodes';
#### target
Type: Element DocumentFragment
The element into which the new children are copied. This element is modified.
#### source
Type: Element DocumentFragment
The element from which the new children are copied.
- insert-text-textarea - Insert text in a textarea (supports Firefox and Undo).
- fit-textarea - Automatically expand a