Skip to content

Commit 264931f

Browse files
committed
fix treeshaking
1 parent 6cc509b commit 264931f

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

packages/svelte/src/internal/client/dom/blocks/svelte-head.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,7 @@ export function head(render_fn) {
5959

6060
try {
6161
block(() => render_fn(anchor), HEAD_EFFECT);
62-
if (hydrating) {
63-
if (hydrate_node === null || /** @type {Comment} */ (hydrate_node).data !== HYDRATION_END) {
64-
hydration_mismatch();
65-
throw HYDRATION_ERROR;
66-
}
67-
}
62+
check_end();
6863
} catch (error) {
6964
// re-mount only this svelte:head
7065
if (was_hydrating && head_anchor && error === HYDRATION_ERROR) {
@@ -102,3 +97,11 @@ export function head(render_fn) {
10297
}
10398
}
10499
}
100+
101+
// treeshaking of hydrate node fails when this is directly in the try-catch
102+
function check_end() {
103+
if (hydrating && /** @type {Comment|null} */ (hydrate_node)?.data !== HYDRATION_END) {
104+
hydration_mismatch();
105+
throw HYDRATION_ERROR;
106+
}
107+
}

0 commit comments

Comments
 (0)