Skip to content

Commit baff378

Browse files
committed
Merge branch 'adjust-boundary-error-message' into simplify-slots
2 parents 3faf4a9 + ed3cb33 commit baff378

File tree

1 file changed

+10
-21
lines changed
  • packages/svelte/src/internal/client/dom/blocks

1 file changed

+10
-21
lines changed

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

Lines changed: 10 additions & 21 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));
@@ -344,7 +333,7 @@ export class Boundary {
344333
}
345334

346335
if (hydrating) {
347-
set_hydrate_node(this.#hydrate_open);
336+
set_hydrate_node(/** @type {TemplateNode} */ (this.#hydrate_open));
348337
next();
349338
set_hydrate_node(remove_nodes());
350339
}

0 commit comments

Comments
 (0)