Skip to content

Commit 6b9f860

Browse files
committed
tweak
1 parent ea0e269 commit 6b9f860

File tree

3 files changed

+15
-20
lines changed

3 files changed

+15
-20
lines changed

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

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export function boundary(node, props, children) {
4747

4848
export class Boundary {
4949
inert = false;
50-
ran = false;
50+
pending = false;
5151

5252
/** @type {Boundary | null} */
5353
parent;
@@ -96,6 +96,8 @@ export class Boundary {
9696

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

99+
this.pending = !!this.#props.pending;
100+
99101
this.#effect = block(() => {
100102
/** @type {Effect} */ (active_effect).b = this;
101103

@@ -124,7 +126,8 @@ export class Boundary {
124126
pause_effect(/** @type {Effect} */ (this.#pending_effect), () => {
125127
this.#pending_effect = null;
126128
});
127-
this.ran = true;
129+
130+
this.pending = false;
128131
}
129132
});
130133
} else {
@@ -137,7 +140,7 @@ export class Boundary {
137140
if (this.#pending_count > 0) {
138141
this.#show_pending_snippet();
139142
} else {
140-
this.ran = true;
143+
this.pending = false;
141144
}
142145
}
143146
}, flags);
@@ -151,14 +154,6 @@ export class Boundary {
151154
return !!this.#props.pending;
152155
}
153156

154-
is_pending() {
155-
if (!this.ran && this.#props.pending) {
156-
return true;
157-
}
158-
159-
return this.#pending_effect !== null && (this.#pending_effect.f & INERT) === 0;
160-
}
161-
162157
/**
163158
* @param {() => Effect | null} fn
164159
*/
@@ -201,7 +196,7 @@ export class Boundary {
201196
}
202197

203198
commit() {
204-
this.ran = true;
199+
this.pending = false;
205200

206201
if (this.#pending_effect) {
207202
pause_effect(this.#pending_effect, () => {
@@ -244,7 +239,7 @@ export class Boundary {
244239
});
245240
}
246241

247-
this.ran = false;
242+
this.pending = true;
248243

249244
this.#main_effect = this.#run(() => {
250245
this.#is_creating_fallback = false;
@@ -254,7 +249,7 @@ export class Boundary {
254249
if (this.#pending_count > 0) {
255250
this.#show_pending_snippet();
256251
} else {
257-
this.ran = true;
252+
this.pending = false;
258253
}
259254
};
260255

packages/svelte/src/internal/client/reactivity/deriveds.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,10 @@ export function async_derived(fn, location) {
132132
prev = promise;
133133

134134
var batch = /** @type {Batch} */ (current_batch);
135-
var ran = !boundary.is_pending();
135+
var pending = boundary.pending;
136136

137137
if (should_suspend) {
138-
(ran ? batch : boundary).increment();
138+
(pending ? boundary : batch).increment();
139139
}
140140

141141
/**
@@ -148,10 +148,10 @@ export function async_derived(fn, location) {
148148
from_async_derived = null;
149149

150150
if (should_suspend) {
151-
(ran ? batch : boundary).decrement();
151+
(pending ? boundary : batch).decrement();
152152
}
153153

154-
if (ran) batch.restore();
154+
if (!pending) batch.restore();
155155

156156
if (error) {
157157
if (error !== STALE_REACTION) {
@@ -179,7 +179,7 @@ export function async_derived(fn, location) {
179179
}
180180
}
181181

182-
if (ran) batch.flush();
182+
if (!pending) batch.flush();
183183
};
184184

185185
promise.then(handler, (e) => handler(null, e || 'unknown'));

packages/svelte/src/internal/client/runtime.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ export function process_effects(batch, root) {
657657
const boundary = effect.b;
658658

659659
if (check_dirtiness(effect)) {
660-
var effects = boundary?.is_pending() ? batch.boundary_async_effects : batch.async_effects;
660+
var effects = boundary?.pending ? batch.boundary_async_effects : batch.async_effects;
661661
effects.push(effect);
662662
}
663663
} else if ((flags & BLOCK_EFFECT) !== 0) {

0 commit comments

Comments
 (0)