diff --git a/.changeset/smooth-pens-exist.md b/.changeset/smooth-pens-exist.md
new file mode 100644
index 000000000000..fcf1b9145689
--- /dev/null
+++ b/.changeset/smooth-pens-exist.md
@@ -0,0 +1,5 @@
+---
+'svelte': patch
+---
+
+fix: always synchronously call `bind:this`
diff --git a/packages/svelte/src/compiler/phases/3-transform/client/visitors/template.js b/packages/svelte/src/compiler/phases/3-transform/client/visitors/template.js
index dfe3e9374329..e9fa7ba8997f 100644
--- a/packages/svelte/src/compiler/phases/3-transform/client/visitors/template.js
+++ b/packages/svelte/src/compiler/phases/3-transform/client/visitors/template.js
@@ -3164,16 +3164,15 @@ export const template_visitors = {
}
const parent = /** @type {import('#compiler').SvelteNode} */ (context.path.at(-1));
- const has_action_directive =
- parent.type === 'RegularElement' && parent.attributes.find((a) => a.type === 'UseDirective');
// Bindings need to happen after attribute updates, therefore after the render effect, and in order with events/actions.
// bind:this is a special case as it's one-way and could influence the render effect.
if (node.name === 'this') {
- state.init.push(
- b.stmt(has_action_directive ? b.call('$.effect', b.thunk(call_expr)) : call_expr)
- );
+ state.init.push(b.stmt(call_expr));
} else {
+ const has_action_directive =
+ parent.type === 'RegularElement' &&
+ parent.attributes.find((a) => a.type === 'UseDirective');
state.after_update.push(
b.stmt(has_action_directive ? b.call('$.effect', b.thunk(call_expr)) : call_expr)
);
diff --git a/packages/svelte/tests/runtime-legacy/samples/apply-directives-in-order-2/_config.js b/packages/svelte/tests/runtime-legacy/samples/apply-directives-in-order-2/_config.js
index bdf3e70919f4..98022d73edd1 100644
--- a/packages/svelte/tests/runtime-legacy/samples/apply-directives-in-order-2/_config.js
+++ b/packages/svelte/tests/runtime-legacy/samples/apply-directives-in-order-2/_config.js
@@ -22,6 +22,7 @@ export default test({
}
assert.deepEqual(value, [
+ 'bind:this true',
'1',
'2',
'3',
diff --git a/packages/svelte/tests/runtime-legacy/samples/apply-directives-in-order-2/main.svelte b/packages/svelte/tests/runtime-legacy/samples/apply-directives-in-order-2/main.svelte
index e91c4b6a1497..c536d722b537 100644
--- a/packages/svelte/tests/runtime-legacy/samples/apply-directives-in-order-2/main.svelte
+++ b/packages/svelte/tests/runtime-legacy/samples/apply-directives-in-order-2/main.svelte
@@ -1,29 +1,86 @@
@@ -31,4 +88,4 @@
-
+