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
pull/16899/head
Rich Harris 2 days ago committed by GitHub
parent 30e2b23b59
commit 2b49a5e3c0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: flush when pending boundaries resolve

@ -285,6 +285,13 @@ export class Boundary {
this.#anchor.before(this.#offscreen_fragment); this.#anchor.before(this.#offscreen_fragment);
this.#offscreen_fragment = null; this.#offscreen_fragment = null;
} }
// TODO this feels like a little bit of a kludge, but until we
// overhaul the boundary/batch relationship it's probably
// the most pragmatic solution available to us
queue_micro_task(() => {
Batch.ensure().flush();
});
} }
} }

@ -0,0 +1,11 @@
import { tick } from 'svelte';
import { test } from '../../test';
export default test({
mode: ['client', 'hydrate'],
async test({ assert, target }) {
await tick();
assert.htmlEqual(target.innerHTML, '<div>attachment ran</div>');
}
});

@ -0,0 +1,9 @@
{#if await true}
<div
{@attach (node) => {
node.textContent = 'attachment ran';
}}
>
attachment did not run
</div>
{/if}
Loading…
Cancel
Save