Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/swift-starfishes-knock.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: flush when pending boundaries resolve
8 changes: 8 additions & 0 deletions packages/svelte/src/internal/client/dom/blocks/boundary.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { Batch, current_batch, effect_pending_updates } from '../../reactivity/b
import { internal_set, source } from '../../reactivity/sources.js';
import { tag } from '../../dev/tracing.js';
import { createSubscriber } from '../../../../reactivity/create-subscriber.js';
import { flushSync } from 'svelte';

/**
* @typedef {{
Expand Down Expand Up @@ -285,6 +286,13 @@ export class Boundary {
this.#anchor.before(this.#offscreen_fragment);
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();
});
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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>');
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{#if await true}
<div
{@attach (node) => {
node.textContent = 'attachment ran';
}}
>
attachment did not run
</div>
{/if}
Loading