Skip to content

Commit 2b49a5e

Browse files
authored
fix: flush when pending boundaries resolve (#16897)
* fix: flush when pending boundaries resolve * note to self * Update packages/svelte/src/internal/client/dom/blocks/boundary.js
1 parent 30e2b23 commit 2b49a5e

File tree

4 files changed

+32
-0
lines changed

4 files changed

+32
-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: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,13 @@ export class Boundary {
285285
this.#anchor.before(this.#offscreen_fragment);
286286
this.#offscreen_fragment = null;
287287
}
288+
289+
// TODO this feels like a little bit of a kludge, but until we
290+
// overhaul the boundary/batch relationship it's probably
291+
// the most pragmatic solution available to us
292+
queue_micro_task(() => {
293+
Batch.ensure().flush();
294+
});
288295
}
289296
}
290297

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)