Skip to content

Svelte 5: Nested form control bindings causes runtime error #11941

@Hugos68

Description

@Hugos68

Describe the bug

When binding to inputs in nested forms, the binding fails and a runtime error is thrown:

<form>
	<form>
			<input bind:value />
	</form>
</form>

Although nested forms are not valid according to the HTML spec, the error should be either friendlier or not throw at all since it worked just fine in Svelte 4.

Reproduction

https://svelte-5-preview.vercel.app/#H4sIAAAAAAAACkWM2wrDIBBEf0WWQloQfLe20O-ofbDJCoI3dA2EkH8vNoEwL2eGw6xgnccK8r1CNAFBwitn4EBL7qXO6AmBQ02tjH1RdSwu01NHTR6JzcY3ZA92qWQIr8Nwu-uoxGlFZVMJf_-kHuVibsS-Lk5yfxG7JQ7tAOAQ0uSswwkklYbbZ_sBkmW8mbgAAAA=

Logs

Cannot read properties of null (reading 'addEventListener')

in App.svelte

System Info

running Svelte compiler version 5.0.0-next.151

Severity

blocking an upgrade

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions