Package Exports
- domdiff
- domdiff/cjs/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 (domdiff) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
domdiff
A vDOM-less implementation of the snabbdom diffing logic.
Signature
futureNodes = domdiff(
parentNode, // where changes happen
currentNodes, // Array of current items/nodes
futureNodes, // Array of future items/nodes (returned)
getNode, // optional way to retrieve a node from an item
beforeNode // optional item/node to use as insertBefore delimiter
);
How to import it:
- via CDN, as global variable:
https://unpkg.com/domdiff
- via ESM, as external module:
https://unpkg.com/domdiff/esm/index.js
- via CJS:
const EventTarget = require('domdiff').default;
( orrequire('domdiff/cjs').default
) - via bundlers/transpilers:
import domdiff from 'domdiff';
( orfrom 'domdiff/esm'
)
Example
var nodes = {
a: document.createTextNode('a'),
b: document.createTextNode('b'),
c: document.createTextNode('c')
};
var parentNode = document.createElement('p');
var childNodes = [nodes.a, nodes.c];
parentNode.append(...childNodes);
parentNode.textContent;
// "ac"
childNodes = domdiff(
parentNode,
childNodes,
[nodes.a, nodes.b, nodes.c]
);
parentNode.textContent;
// "abc"
Compatibility:
Every. JavaScript. Engine.