Skip to content

Commit 57d6737

Browse files
committed
breaking: avoid flushing queued updates on mount/hydrat
1 parent 621eb76 commit 57d6737

File tree

5 files changed

+12
-2
lines changed

5 files changed

+12
-2
lines changed

.changeset/slow-gorillas-yawn.md

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+
breaking: avoid flushing queued updates on mount/hydrate

packages/svelte/src/internal/client/render.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,7 @@ export function set_text(text, value) {
7979
*/
8080
export function mount(component, options) {
8181
const anchor = options.anchor ?? options.target.appendChild(empty());
82-
// Don't flush previous effects to ensure order of outer effects stays consistent
83-
return flush_sync(() => _mount(component, { ...options, anchor }), false);
82+
return _mount(component, { ...options, anchor });
8483
}
8584

8685
/**

packages/svelte/tests/runtime-browser/samples/bind-playbackrate/_config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
import { flushSync } from 'svelte';
12
import { test, ok } from '../../assert';
23

34
export default test({
45
mode: ['client'],
56
async test({ assert, target }) {
7+
flushSync();
68
const audio = target.querySelector('audio');
79
const button = target.querySelector('button');
810
ok(audio);

packages/svelte/tests/runtime-browser/samples/head-script/_config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
import { flushSync } from 'svelte';
12
import { test } from '../../assert';
23

34
export default test({
45
test({ assert, window }) {
6+
flushSync();
57
document.dispatchEvent(new Event('DOMContentLoaded'));
68
assert.equal(window.document.querySelector('button')?.textContent, 'Hello world');
79
}

packages/svelte/tests/runtime-browser/samples/sole-script-tag/_config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
import { flushSync } from 'svelte';
12
import { test } from '../../assert';
23

34
export default test({
45
// Test that template with sole script tag does execute when instantiated in the client.
56
// Needs to be in this test suite because JSDOM does not quite get this right.
67
mode: ['client'],
78
test({ window, assert }) {
9+
flushSync();
810
// In here to give effects etc time to execute
911
assert.htmlEqual(window.document.body.innerHTML, 'this should be executed');
1012
}

0 commit comments

Comments
 (0)