WebReflection / Udomdiff
Licence: isc
An essential diffing algorithm for µhtml.
Stars: ✭ 62
Programming Languages
javascript
184084 projects - #8 most used programming language
µdomdiff
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
);
get
and how does it work?
What is 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 aninsertBefore
operation -
get(node, -0)
to get the node to use for aninsertAfter
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');
( orrequire('udomdiff/cjs')
) - via bundlers/transpilers:
import udomdiff from 'udomdiff';
( orfrom 'udomdiff/esm'
)
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].