diff --git a/packages/svelte/src/internal/client/dom/blocks/boundary.js b/packages/svelte/src/internal/client/dom/blocks/boundary.js index e7141e06a8..a6dfc46057 100644 --- a/packages/svelte/src/internal/client/dom/blocks/boundary.js +++ b/packages/svelte/src/internal/client/dom/blocks/boundary.js @@ -47,7 +47,7 @@ export function boundary(node, props, children) { export class Boundary { inert = false; - ran = false; + pending = false; /** @type {Boundary | null} */ parent; @@ -96,6 +96,8 @@ export class Boundary { this.parent = /** @type {Effect} */ (active_effect).b; + this.pending = !!this.#props.pending; + this.#effect = block(() => { /** @type {Effect} */ (active_effect).b = this; @@ -124,7 +126,8 @@ export class Boundary { pause_effect(/** @type {Effect} */ (this.#pending_effect), () => { this.#pending_effect = null; }); - this.ran = true; + + this.pending = false; } }); } else { @@ -137,7 +140,7 @@ export class Boundary { if (this.#pending_count > 0) { this.#show_pending_snippet(); } else { - this.ran = true; + this.pending = false; } } }, flags); @@ -151,14 +154,6 @@ export class Boundary { return !!this.#props.pending; } - is_pending() { - if (!this.ran && this.#props.pending) { - return true; - } - - return this.#pending_effect !== null && (this.#pending_effect.f & INERT) === 0; - } - /** * @param {() => Effect | null} fn */ @@ -201,7 +196,7 @@ export class Boundary { } commit() { - this.ran = true; + this.pending = false; if (this.#pending_effect) { pause_effect(this.#pending_effect, () => { @@ -244,7 +239,7 @@ export class Boundary { }); } - this.ran = false; + this.pending = true; this.#main_effect = this.#run(() => { this.#is_creating_fallback = false; @@ -254,7 +249,7 @@ export class Boundary { if (this.#pending_count > 0) { this.#show_pending_snippet(); } else { - this.ran = true; + this.pending = false; } }; diff --git a/packages/svelte/src/internal/client/reactivity/deriveds.js b/packages/svelte/src/internal/client/reactivity/deriveds.js index c0f55c2614..a98ea1cff8 100644 --- a/packages/svelte/src/internal/client/reactivity/deriveds.js +++ b/packages/svelte/src/internal/client/reactivity/deriveds.js @@ -132,10 +132,10 @@ export function async_derived(fn, location) { prev = promise; var batch = /** @type {Batch} */ (current_batch); - var ran = !boundary.is_pending(); + var pending = boundary.pending; if (should_suspend) { - (ran ? batch : boundary).increment(); + (pending ? boundary : batch).increment(); } /** @@ -148,10 +148,10 @@ export function async_derived(fn, location) { from_async_derived = null; if (should_suspend) { - (ran ? batch : boundary).decrement(); + (pending ? boundary : batch).decrement(); } - if (ran) batch.restore(); + if (!pending) batch.restore(); if (error) { if (error !== STALE_REACTION) { @@ -179,7 +179,7 @@ export function async_derived(fn, location) { } } - if (ran) batch.flush(); + if (!pending) batch.flush(); }; promise.then(handler, (e) => handler(null, e || 'unknown')); diff --git a/packages/svelte/src/internal/client/runtime.js b/packages/svelte/src/internal/client/runtime.js index d3303704bc..16b136de1a 100644 --- a/packages/svelte/src/internal/client/runtime.js +++ b/packages/svelte/src/internal/client/runtime.js @@ -657,7 +657,7 @@ export function process_effects(batch, root) { const boundary = effect.b; if (check_dirtiness(effect)) { - var effects = boundary?.is_pending() ? batch.boundary_async_effects : batch.async_effects; + var effects = boundary?.pending ? batch.boundary_async_effects : batch.async_effects; effects.push(effect); } } else if ((flags & BLOCK_EFFECT) !== 0) {