Skip to content

Commit 48293d2

Browse files
committed
fix
1 parent 6f8abda commit 48293d2

File tree

2 files changed

+14
-11
lines changed
  • packages/svelte
    • src/internal/client/reactivity
    • tests/runtime-runes/samples/async-derived-in-if

2 files changed

+14
-11
lines changed

Diff for: packages/svelte/src/internal/client/reactivity/batch.js

+14-6
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,7 @@ export class Batch {
107107
this.render_effects = [];
108108
this.effects = [];
109109

110-
// commit changes
111-
for (const fn of this.#callbacks) {
112-
fn();
113-
}
114-
115-
this.#callbacks.clear();
110+
this.commit();
116111

117112
flush_queued_effects(render_effects);
118113
flush_queued_effects(effects);
@@ -174,12 +169,25 @@ export class Batch {
174169
fn();
175170
}
176171

172+
commit() {
173+
// commit changes
174+
for (const fn of this.#callbacks) {
175+
fn();
176+
}
177+
178+
this.#callbacks.clear();
179+
}
180+
177181
increment() {
178182
this.#pending += 1;
179183
}
180184

181185
decrement() {
182186
this.#pending -= 1;
187+
188+
if (this.#pending === 0) {
189+
this.commit();
190+
}
183191
}
184192

185193
settled() {

Diff for: packages/svelte/tests/runtime-runes/samples/async-derived-in-if/_config.js

-5
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@ import { flushSync } from 'svelte';
22
import { test } from '../../test';
33

44
export default test({
5-
html: `
6-
<button>show</button>
7-
<p>pending</p>
8-
`,
9-
105
async test({ assert, target }) {
116
const button = target.querySelector('button');
127

0 commit comments

Comments
 (0)