From 6b058526f39495a5cbff5c01e0005dbfd35ffe44 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Tue, 11 Feb 2025 09:58:40 -0500 Subject: [PATCH] more --- .../svelte/src/internal/client/constants.js | 1 - .../internal/client/dom/blocks/boundary.js | 23 +++++++------------ .../svelte/src/internal/client/runtime.js | 5 ++-- 3 files changed, 10 insertions(+), 19 deletions(-) diff --git a/packages/svelte/src/internal/client/constants.js b/packages/svelte/src/internal/client/constants.js index cc04b66a4b..530f72b61c 100644 --- a/packages/svelte/src/internal/client/constants.js +++ b/packages/svelte/src/internal/client/constants.js @@ -23,7 +23,6 @@ export const EFFECT_PRESERVED = 1 << 21; // effects with this flag should not be // Flags used for async export const REACTION_IS_UPDATING = 1 << 22; -export const BOUNDARY_SUSPENDED = 1 << 23; export const STATE_SYMBOL = Symbol('$state'); export const STATE_SYMBOL_METADATA = Symbol('$state metadata'); diff --git a/packages/svelte/src/internal/client/dom/blocks/boundary.js b/packages/svelte/src/internal/client/dom/blocks/boundary.js index c5f6a358a0..e594793996 100644 --- a/packages/svelte/src/internal/client/dom/blocks/boundary.js +++ b/packages/svelte/src/internal/client/dom/blocks/boundary.js @@ -2,7 +2,6 @@ import { BOUNDARY_EFFECT, - BOUNDARY_SUSPENDED, EFFECT_PRESERVED, EFFECT_RAN, EFFECT_TRANSPARENT, @@ -56,6 +55,8 @@ export function set_active_boundary(boundary) { */ export class Boundary { + suspended = false; + /** @type {TemplateNode} */ #anchor; @@ -111,10 +112,7 @@ export class Boundary { const reset = () => { this.#pending_count = 0; - - if ((this.#effect.f & BOUNDARY_SUSPENDED) !== 0) { - this.#effect.f ^= BOUNDARY_SUSPENDED; - } + this.suspended = false; if (this.#failed_effect !== null) { pause_effect(this.#failed_effect, () => { @@ -133,7 +131,7 @@ export class Boundary { }); if (this.#pending_count > 0) { - this.#effect.f |= BOUNDARY_SUSPENDED; + this.suspended = true; this.#show_pending_snippet(true); } }; @@ -142,10 +140,7 @@ export class Boundary { boundary_effect.fn = (/** @type {unknown} */ input, /** @type {any} */ payload) => { if (input === ASYNC_INCREMENT) { // post-init, show the pending snippet after a timeout - if ( - (boundary_effect.f & BOUNDARY_SUSPENDED) === 0 && - (boundary_effect.f & EFFECT_RAN) !== 0 - ) { + if (!this.suspended && (boundary_effect.f & EFFECT_RAN) !== 0) { var start = raf.now(); var end = start + (this.#props.showPendingAfter ?? 500); @@ -157,7 +152,7 @@ export class Boundary { }); } - boundary_effect.f |= BOUNDARY_SUSPENDED; + this.suspended = true; this.#pending_count++; return; @@ -266,7 +261,7 @@ export class Boundary { this.#main_effect = branch(() => children(this.#anchor)); if (this.#pending_count > 0) { - boundary_effect.f |= BOUNDARY_SUSPENDED; + this.suspended = true; this.#show_pending_snippet(true); } } @@ -363,9 +358,7 @@ export class Boundary { return; } - if ((this.#effect.f & BOUNDARY_SUSPENDED) !== 0) { - this.#effect.f ^= BOUNDARY_SUSPENDED; - } + this.suspended = false; for (const e of this.#render_effects) { try { diff --git a/packages/svelte/src/internal/client/runtime.js b/packages/svelte/src/internal/client/runtime.js index b281eb104c..4027a094ad 100644 --- a/packages/svelte/src/internal/client/runtime.js +++ b/packages/svelte/src/internal/client/runtime.js @@ -24,8 +24,7 @@ import { LEGACY_DERIVED_PROP, DISCONNECTED, BOUNDARY_EFFECT, - REACTION_IS_UPDATING, - BOUNDARY_SUSPENDED + REACTION_IS_UPDATING } from './constants.js'; import { flush_idle_tasks, @@ -835,7 +834,7 @@ function process_effects(effect, collected_effects, boundary) { process_effects(current_effect, collected_effects, b); - if ((current_effect.f & BOUNDARY_SUSPENDED) === 0) { + if (!b.suspended) { // no more async work to happen b.commit(); }