Morphlex is a ~2KB (gzipped) DOM morphing library that transforms one DOM tree to match another while preserving element state and making minimal changes.
Installation#
npm install morphlex
Or use it directly from a CDN:
<script type="module">
import { morph } from "https://www.unpkg.com/morphlex@0.0.17/dist/morphlex.min.js"
</script>
Usage#
import { morph, morphInner } from "morphlex"
// Morph the entire element
morph(currentNode, referenceNode)
// Morph only the inner content
morphInner(currentNode, referenceNode)