Skip to content

Commit f9cfe20

Browse files
committed
Using no domdiff on empty nodes ... no perf improvements though
1 parent 778d957 commit f9cfe20

4 files changed

Lines changed: 76 additions & 64 deletions

File tree

docs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
It is entirely Web standards based and it adds just the minimal amount of *spices* to the templates literals it's able to understand and optimized for either repeated updates or one-off operations.
88

9-
This page describes, without going into too many details, all the features delivered via this module which is roughly 2.5K once minified and compressed, or even bundled within your project.
9+
This page describes, without going into too many details, all the features delivered via this module which is roughly 2.7K once minified and compressed, or even bundled within your project.
1010

1111
### Content
1212

esm/handler.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,15 @@ export const toggle = (element, value, name) => (
185185
value
186186
);
187187

188+
const noDOMDiff = (node, value) => {
189+
const nodes = [];
190+
for (let i = 0; i < value.length; i++)
191+
nodes.push(diffFragment(value[i], 1));
192+
nodes.push(node);
193+
node.replaceWith(...nodes);
194+
return value;
195+
};
196+
188197
/**
189198
* @param {Node} node
190199
* @param {Node[]} value
@@ -194,7 +203,10 @@ export const toggle = (element, value, name) => (
194203
*/
195204
export const array = (node, value, _, prev) => (
196205
value.length ?
197-
udomdiff(node.parentNode, prev, value, diffFragment, node) :
206+
(prev === empty ?
207+
noDOMDiff(node, value) :
208+
udomdiff(node.parentNode, prev, value, diffFragment, node)
209+
) :
198210
(prev.length && drop(prev[0], prev.at(-1), false), empty)
199211
);
200212

package-lock.json

Lines changed: 60 additions & 60 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
"@rollup/plugin-terser": "^0.4.4",
2727
"ascjs": "^6.0.3",
2828
"c8": "^8.0.1",
29-
"linkedom": "^0.16.5",
30-
"rollup": "^4.9.1",
29+
"linkedom": "^0.16.6",
30+
"rollup": "^4.9.2",
3131
"typescript": "^5.3.3"
3232
},
3333
"module": "./esm/index.js",

0 commit comments

Comments
 (0)