breaking: avoid flushing queued updates on mount/hydrat

pull/12587/head
Dominic Gannaway 2 years ago
parent 621eb76e1e
commit 57d673738b

@ -0,0 +1,5 @@
---
'svelte': patch
---
breaking: avoid flushing queued updates on mount/hydrate

@ -79,8 +79,7 @@ export function set_text(text, value) {
*/
export function mount(component, options) {
const anchor = options.anchor ?? options.target.appendChild(empty());
// Don't flush previous effects to ensure order of outer effects stays consistent
return flush_sync(() => _mount(component, { ...options, anchor }), false);
return _mount(component, { ...options, anchor });
}
/**

@ -1,8 +1,10 @@
import { flushSync } from 'svelte';
import { test, ok } from '../../assert';
export default test({
mode: ['client'],
async test({ assert, target }) {
flushSync();
const audio = target.querySelector('audio');
const button = target.querySelector('button');
ok(audio);

@ -1,7 +1,9 @@
import { flushSync } from 'svelte';
import { test } from '../../assert';
export default test({
test({ assert, window }) {
flushSync();
document.dispatchEvent(new Event('DOMContentLoaded'));
assert.equal(window.document.querySelector('button')?.textContent, 'Hello world');
}

@ -1,3 +1,4 @@
import { flushSync } from 'svelte';
import { test } from '../../assert';
export default test({
@ -5,6 +6,7 @@ export default test({
// Needs to be in this test suite because JSDOM does not quite get this right.
mode: ['client'],
test({ window, assert }) {
flushSync();
// In here to give effects etc time to execute
assert.htmlEqual(window.document.body.innerHTML, 'this should be executed');
}

Loading…
Cancel
Save