JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 12
  • Score
    100M100P100Q37103F
  • License ISC

Fast & tiny DOM swapper.

Package Exports

  • swapdom
  • swapdom/swap-inflate.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (swapdom) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

swapdom test npm version

Fast & tiny DOM swapper.

import swap from './swap-inflate.js'

swap(parentNode, oldNodes, newNodes, endNode)

swap-deflate.js strategy is smaller (208b), but slower and doesn't support live collections. swap-inflate.js strategy is bigger (363b), but faster and support live collections.

Provide custom mutators as:

swap.same = (a,b) => a?.isSameNode(b)
swap.replace = (a,b, parent) => a.replaceWith(b)
swap.insert = (a,b, parent) => a ? a.before(b) : parent.append(b)
swap.remove = (a, parent) => a.remove()

See benchmark.