Skip to content

Commit cf1e72f

Browse files
committed
fix treeshaking
1 parent e93905c commit cf1e72f

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

packages/svelte/scripts/check-treeshakeability.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ const bundle = await bundle_code(
109109
).js.code
110110
);
111111

112-
if (!bundle.includes('hydrate_nodes')) {
112+
if (!bundle.includes('hydrate_nodes') && !bundle.includes('hydrate_anchor')) {
113113
// eslint-disable-next-line no-console
114114
console.error(`✅ Hydration code treeshakeable`);
115115
} else {

packages/svelte/src/internal/client/dom/blocks/each.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,11 @@ function each(anchor, flags, get_collection, get_key, render_fn, fallback_fn, re
5757
if (is_controlled) {
5858
var parent_node = /** @type {Element} */ (anchor);
5959

60-
anchor = /** @type {Comment | Text} */ (
61-
hydrate_anchor(parent_node.firstChild ?? parent_node.appendChild(empty()))
62-
);
60+
anchor = hydrating
61+
? /** @type {Comment | Text} */ (
62+
hydrate_anchor(/** @type {Comment | Text} */ (parent_node.firstChild))
63+
)
64+
: parent_node.appendChild(empty());
6365
}
6466

6567
/** @type {import('#client').Effect | null} */

0 commit comments

Comments
 (0)