Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 10 additions & 21 deletions packages/svelte/src/internal/client/dom/blocks/boundary.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ export class Boundary {
/** @type {TemplateNode} */
#anchor;

/** @type {TemplateNode} */
#hydrate_open;
/** @type {TemplateNode | null} */
#hydrate_open = hydrating ? hydrate_node : null;

/** @type {BoundaryProps} */
#props;
Expand Down Expand Up @@ -92,8 +92,6 @@ export class Boundary {

#is_creating_fallback = false;

#server_rendered_pending = false;

/**
* A source containing the number of pending async deriveds/expressions.
* Only created if `$effect.pending()` is used inside the boundary,
Expand Down Expand Up @@ -131,10 +129,6 @@ export class Boundary {
this.#props = props;
this.#children = children;

this.#hydrate_open = hydrate_node;

this.#server_rendered_pending = this.#detect_server_state();

this.parent = /** @type {Effect} */ (active_effect).b;

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

if (hydrating) {
const comment = this.#hydrate_open;
hydrate_next();
if (this.#server_rendered_pending) {

const server_rendered_pending =
/** @type {Comment} */ (comment).nodeType === COMMENT_NODE &&
/** @type {Comment} */ (comment).data === HYDRATION_START_ELSE;

if (server_rendered_pending) {
this.#hydrate_pending_content();
} else {
this.#hydrate_resolved_content();
Expand All @@ -169,17 +169,6 @@ export class Boundary {
}
}

#detect_server_state() {
if (!hydrating || !this.#hydrate_open) return false;

const comment = this.#hydrate_open;
if (comment.nodeType === COMMENT_NODE) {
return /** @type {Comment} */ (comment).data === HYDRATION_START_ELSE;
}

return false;
}

#hydrate_resolved_content() {
try {
this.#main_effect = branch(() => this.#children(this.#anchor));
Expand Down Expand Up @@ -344,7 +333,7 @@ export class Boundary {
}

if (hydrating) {
set_hydrate_node(this.#hydrate_open);
set_hydrate_node(/** @type {TemplateNode} */ (this.#hydrate_open));
next();
set_hydrate_node(remove_nodes());
}
Expand Down
Loading