diff --git a/README.md b/README.md index c508bf9..4bfb24e 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,9 @@ type Options = { onNextNode?: NextNodeCallback; // update the DOM using document.startViewTransition (default: false) transition?: boolean; - // callback to ignore nodes (default: undefined) + // callback to leave nodes alone, on both the old and the new tree: an + // ignored node is never updated, moved or removed, and never counts as one + // of the old children the diff has to prune (default: undefined) shouldIgnoreNode?: (node: Node | null) => boolean; }; ``` diff --git a/package.json b/package.json index a5b522d..d40fd2a 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "files": [ { "path": "./build/index.js", - "maxSize": "1.5 kB" + "maxSize": "1.6 kB" } ] }, diff --git a/src/index.test.ts b/src/index.test.ts index 561c38b..746869b 100644 --- a/src/index.test.ts +++ b/src/index.test.ts @@ -1680,12 +1680,14 @@ describe("Diff test", () => { ], ignoreId: true, }); + // Ignored means untouched: the node keeps its own content ("bar", not the + // incoming "bazz!") and stays put, while its siblings diff as usual. expect(newHTML).toBe( normalize(`
-