Skip to content

Commit 225de57

Browse files
committed
chore: fix hydration treeshaking
1 parent 6a8ab8e commit 225de57

File tree

1 file changed

+9
-20
lines changed
  • packages/svelte/src/internal/client/dom/blocks

1 file changed

+9
-20
lines changed

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

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ export class Boundary {
6363
/** @type {TemplateNode} */
6464
#anchor;
6565

66-
/** @type {TemplateNode} */
67-
#hydrate_open;
66+
/** @type {TemplateNode | null} */
67+
#hydrate_open = hydrating ? hydrate_node : null;
6868

6969
/** @type {BoundaryProps} */
7070
#props;
@@ -92,8 +92,6 @@ export class Boundary {
9292

9393
#is_creating_fallback = false;
9494

95-
#server_rendered_pending = false;
96-
9795
/**
9896
* A source containing the number of pending async deriveds/expressions.
9997
* Only created if `$effect.pending()` is used inside the boundary,
@@ -131,10 +129,6 @@ export class Boundary {
131129
this.#props = props;
132130
this.#children = children;
133131

134-
this.#hydrate_open = hydrate_node;
135-
136-
this.#server_rendered_pending = this.#detect_server_state();
137-
138132
this.parent = /** @type {Effect} */ (active_effect).b;
139133

140134
this.#pending = !!this.#props.pending;
@@ -143,8 +137,14 @@ export class Boundary {
143137
/** @type {Effect} */ (active_effect).b = this;
144138

145139
if (hydrating) {
140+
const comment = this.#hydrate_open;
146141
hydrate_next();
147-
if (this.#server_rendered_pending) {
142+
143+
const server_rendered_pending =
144+
/** @type {Comment} */ (comment).nodeType === COMMENT_NODE &&
145+
/** @type {Comment} */ (comment).data === HYDRATION_START_ELSE;
146+
147+
if (server_rendered_pending) {
148148
this.#hydrate_pending_content();
149149
} else {
150150
this.#hydrate_resolved_content();
@@ -169,17 +169,6 @@ export class Boundary {
169169
}
170170
}
171171

172-
#detect_server_state() {
173-
if (!hydrating || !this.#hydrate_open) return false;
174-
175-
const comment = this.#hydrate_open;
176-
if (comment.nodeType === COMMENT_NODE) {
177-
return /** @type {Comment} */ (comment).data === HYDRATION_START_ELSE;
178-
}
179-
180-
return false;
181-
}
182-
183172
#hydrate_resolved_content() {
184173
try {
185174
this.#main_effect = branch(() => this.#children(this.#anchor));

0 commit comments

Comments
 (0)