Skip to content

Commit 41e34be

Browse files
committed
fix: flush when pending boundaries resolve
1 parent 30e2b23 commit 41e34be

File tree

4 files changed

+30
-0
lines changed

4 files changed

+30
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: flush when pending boundaries resolve

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import { Batch, current_batch, effect_pending_updates } from '../../reactivity/b
3333
import { internal_set, source } from '../../reactivity/sources.js';
3434
import { tag } from '../../dev/tracing.js';
3535
import { createSubscriber } from '../../../../reactivity/create-subscriber.js';
36+
import { flushSync } from 'svelte';
3637

3738
/**
3839
* @typedef {{
@@ -285,6 +286,10 @@ export class Boundary {
285286
this.#anchor.before(this.#offscreen_fragment);
286287
this.#offscreen_fragment = null;
287288
}
289+
290+
queue_micro_task(() => {
291+
Batch.ensure().flush();
292+
});
288293
}
289294
}
290295

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { tick } from 'svelte';
2+
import { test } from '../../test';
3+
4+
export default test({
5+
mode: ['client', 'hydrate'],
6+
7+
async test({ assert, target }) {
8+
await tick();
9+
assert.htmlEqual(target.innerHTML, '<div>attachment ran</div>');
10+
}
11+
});
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{#if await true}
2+
<div
3+
{@attach (node) => {
4+
node.textContent = 'attachment ran';
5+
}}
6+
>
7+
attachment did not run
8+
</div>
9+
{/if}

0 commit comments

Comments
 (0)