From 72ab4fc21a76392297a157527488d0e791b0b2f5 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Tue, 11 Feb 2025 09:25:20 -0500 Subject: [PATCH] more --- .../internal/client/dom/blocks/boundary.js | 86 +++++++++---------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/packages/svelte/src/internal/client/dom/blocks/boundary.js b/packages/svelte/src/internal/client/dom/blocks/boundary.js index 43ad99d99c..5054bbcd6e 100644 --- a/packages/svelte/src/internal/client/dom/blocks/boundary.js +++ b/packages/svelte/src/internal/client/dom/blocks/boundary.js @@ -154,47 +154,7 @@ export class Boundary { if (this.#pending_count > 0) { boundary_effect.f |= BOUNDARY_SUSPENDED; - show_pending_snippet(true); - } - }; - - /** - * @param {boolean} initial - */ - const show_pending_snippet = (initial) => { - const pending = this.#props.pending; - - if (pending !== undefined) { - // TODO can this be false? - if (this.#main_effect !== null) { - this.#offscreen_fragment = document.createDocumentFragment(); - move_effect(this.#main_effect, this.#offscreen_fragment); - } - - if (this.#pending_effect === null) { - this.#pending_effect = branch(() => pending(this.#anchor)); - } - - // TODO do we want to differentiate between initial render and updates here? - if (!initial) { - this.#keep_pending_snippet = true; - - var end = raf.now() + (this.#props.showPendingFor ?? 300); - - loop((now) => { - if (now >= end) { - this.#keep_pending_snippet = false; - this.commit(); - return false; - } - - return true; - }); - } - } else if (this.#parent) { - throw new Error('TODO show pending snippet on parent'); - } else { - throw new Error('no pending snippet to show'); + this.#show_pending_snippet(true); } }; @@ -213,7 +173,7 @@ export class Boundary { if (this.#pending_count === 0) return false; if (now < end) return true; - show_pending_snippet(false); + this.#show_pending_snippet(false); }); } @@ -315,7 +275,7 @@ export class Boundary { if (this.#pending_count > 0) { boundary_effect.f |= BOUNDARY_SUSPENDED; - show_pending_snippet(true); + this.#show_pending_snippet(true); } } @@ -356,6 +316,46 @@ export class Boundary { } } + /** + * @param {boolean} initial + */ + #show_pending_snippet(initial) { + const pending = this.#props.pending; + + if (pending !== undefined) { + // TODO can this be false? + if (this.#main_effect !== null) { + this.#offscreen_fragment = document.createDocumentFragment(); + move_effect(this.#main_effect, this.#offscreen_fragment); + } + + if (this.#pending_effect === null) { + this.#pending_effect = branch(() => pending(this.#anchor)); + } + + // TODO do we want to differentiate between initial render and updates here? + if (!initial) { + this.#keep_pending_snippet = true; + + var end = raf.now() + (this.#props.showPendingFor ?? 300); + + loop((now) => { + if (now >= end) { + this.#keep_pending_snippet = false; + this.commit(); + return false; + } + + return true; + }); + } + } else if (this.#parent) { + throw new Error('TODO show pending snippet on parent'); + } else { + throw new Error('no pending snippet to show'); + } + } + /** @param {() => void} fn */ add_callback(fn) { this.#callbacks.add(fn);