diff --git a/.changeset/cool-turtles-travel.md b/.changeset/cool-turtles-travel.md
new file mode 100644
index 0000000000..31145e6e76
--- /dev/null
+++ b/.changeset/cool-turtles-travel.md
@@ -0,0 +1,5 @@
+---
+'svelte': patch
+---
+
+fix: ensure custom elements do not sync flush on mount
diff --git a/packages/svelte/src/legacy/legacy-client.js b/packages/svelte/src/legacy/legacy-client.js
index a11f3f9cee..ff145f3fb2 100644
--- a/packages/svelte/src/legacy/legacy-client.js
+++ b/packages/svelte/src/legacy/legacy-client.js
@@ -110,7 +110,10 @@ class Svelte4Component {
recover: options.recover
});
- flush_sync();
+ // We don't flush_sync for custom element wrappers
+ if (!options?.props?.$$host) {
+ flush_sync();
+ }
this.#events = props.$$events;
diff --git a/packages/svelte/tests/runtime-browser/custom-elements-samples/effect-sequence/_config.js b/packages/svelte/tests/runtime-browser/custom-elements-samples/effect-sequence/_config.js
new file mode 100644
index 0000000000..84eb9bc13a
--- /dev/null
+++ b/packages/svelte/tests/runtime-browser/custom-elements-samples/effect-sequence/_config.js
@@ -0,0 +1,20 @@
+import { test } from '../../assert';
+const tick = () => Promise.resolve();
+
+export default test({
+ async test({ assert, target }) {
+ let changed = false;
+
+ target.innerHTML = '';
+
+ await tick(); // wait for element to upgrade
+
+ target.addEventListener('change', () => {
+ changed = true;
+ });
+
+ await tick(); // wait for effect
+
+ assert.equal(changed, true);
+ }
+});
diff --git a/packages/svelte/tests/runtime-browser/custom-elements-samples/effect-sequence/main.svelte b/packages/svelte/tests/runtime-browser/custom-elements-samples/effect-sequence/main.svelte
new file mode 100644
index 0000000000..0f639d6e57
--- /dev/null
+++ b/packages/svelte/tests/runtime-browser/custom-elements-samples/effect-sequence/main.svelte
@@ -0,0 +1,7 @@
+
+
+
diff --git a/packages/svelte/tests/runtime-browser/custom-elements-samples/escaped-css/_config.js b/packages/svelte/tests/runtime-browser/custom-elements-samples/escaped-css/_config.js
index 0cbfd63821..892da67df7 100644
--- a/packages/svelte/tests/runtime-browser/custom-elements-samples/escaped-css/_config.js
+++ b/packages/svelte/tests/runtime-browser/custom-elements-samples/escaped-css/_config.js
@@ -5,6 +5,7 @@ export default test({
async test({ assert, target }) {
target.innerHTML = '';
await tick();
+ await tick();
/** @type {any} */
const ce = target.querySelector('custom-element');
const icon = ce.shadowRoot.querySelector('.icon');