JSPM

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

An essential diffing algorithm for µhtml

Package Exports

  • udomdiff
  • udomdiff/cjs/index.js
  • udomdiff/esm/index.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 (udomdiff) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

µdomdiff

Build Status Coverage Status

a different tree

Social Media Photo by Christopher Rusev on Unsplash

An essential diffing algorithm for µhtml.

Signature

futureNodes = udomdiff(
  parentNode,           // where changes happen
  [...currentNodes],    // Array of current items/nodes
  [...futureNodes],     // Array of future items/nodes (returned)
  get(node, toDoWhat),  // a callback to retrieve the node
  before                // the anchored node to insertBefore
);

What is get and how does it work?

You can find all info from domdiff, as it's exactly the same concept:

  • get(node, 1) to retrieve the node that's being appended
  • get(node, 0) to get the node to use for an insertBefore operation
  • get(node, -0) to get the node to use for an insertAfter operation
  • get(node, -1) to retrieve the node that's being removed

If you don't care about any of those second arguments values, const get = o => o; is a valid get too.

How to import it:

  • via CDN, as global variable: https://unpkg.com/udomdiff
  • via ESM, as external module: import udomdiff from 'https://unpkg.com/udomdiff/esm/index.js'
  • via CJS: const udomdiff = require('udomdiff'); ( or require('udomdiff/cjs') )
  • via bundlers/transpilers: import udomdiff from 'udomdiff'; ( or from 'udomdiff/esm' )