snapshot-node

Clone a HTML node & apply computed styles recursively to the cloned node.

Usage no npm install needed!

<script type="module">
  import snapshotNode from 'https://cdn.skypack.dev/snapshot-node';
</script>

README

snapshot-node

Build Status

Clone a HTML node & apply computed styles recursively to the cloned node.

Install

npm install snapshot-node --save

Usage

import {snapshotNode} from 'snapshot-node'

const target = document.getElementById('target')
const snapshot = snapshotNode(target)

// target element and its ancestors's computed styles will be saved as inline styles of snapshot's corresponding element.

See test for a more complete example.

Limitations

Only HTMLElement & SVGElements' styles are snapshotted.

License

MIT