Skip to content

[Svelte 5] bind:this on components not working #10026

@terrywh

Description

@terrywh

Describe the bug

'undefined' is logged with the following:

https://svelte-5-preview.vercel.app/#H4sIAAAAAAAAE41QwUrFMBD8lXXx8B6U9nmtbUHwL4wHX5raYJoNyfYVCfl32Rb0IIK3nWVmZ3YyTtaZhO1LRv-2GGzxKQSskD-DgHQzjg1WmGiNWjZd0tEGHpRXbJdAkeHZLARTpAUU1o2g-tApfBSaMwzGyV6gVzytXrMlD2mm7XSGLEvFmnwiZ2pH76eDf971Rfmu-bH13Whvu3-3O2925LlX-HC5KISr9WPLs019Pm6UodszHYrrykweyGtn9UefJUEZDn-Zd1JzsAbxFS-scKHRTtaM2HJcTam-65LT_-1LisggQugVbhTdqBAK9HAfIoV0kn9_vzob56iCLMJy91ek1_IF6Flw4s0BAAA=

Reproduction

  • app.svelte
<script>
	import Demo from "./Demo.svelte";
	let elDemo;

	function show() {
		console.log(elDemo);
	}
</script>

<div>
	<Demo width="100" bind:this={elDemo}></Demo>
	<button onclick={show}>
		show
	</button>
</div>
  • Demo.svelte
<script>
	let { name ="world" } = $props();
</script>

<div>hello, {name}!</div>

Logs

undefined xN

System Info

MacOS/Chrome

Severity

blocking an upgrade

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions