Skip to content

Input with function bindings not working when not in root element #14623

@henrykrinkle01

Description

@henrykrinkle01

Describe the bug

I'm testing the new function binding feature but can't get it to work for some reason. After comparing with the official demo, I found that putting an input inside a label makes it stop working:

<script>
	let value = $state(0);
</script>

{value}
<br />
<label for="workingInput">Working input</label> <br />
<input id="workingInput" bind:value={() => value + 1, (v) => (value = v - 1)} />
<br />
<label for="notWorkingInput">
	Not working Input <br />
	<input id="notWorkingInput" bind:value={() => value + 1, (v) => (value = v - 1)} />
</label>

Reproduction

https://svelte.dev/playground/1b9f67eca20944acb6376ab676204ecb?version=5.9.0

Logs

No response

System Info

System:
    OS: Windows 10 10.0.17763
    CPU: (32) x64 AMD Ryzen 9 3950X 16-Core Processor
    Memory: 34.65 GB / 63.94 GB
  Binaries:
    Node: 22.5.1 - C:\Program Files\nodejs\node.EXE
    npm: 10.8.3 - C:\Program Files\nodejs\npm.CMD
    pnpm: 9.10.0 - C:\ProgramData\chocolatey\bin\pnpm.EXE
  Browsers:
    Chrome: 131.0.6778.109
    Internet Explorer: 11.0.17763.2989

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