-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
undefined value on input and other elements #4467
Comments
Is this the same as #3569? |
Not really. Its more about the inconsistency when not using two-way binding vs using two-way binding. |
That doesn't work as expected when using Edit: it's a detail, just worth pointing out that this workaround has some unexpected effect. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This is fixed in Svelte 5 |
Describe the bug
The value prop behaves differently in various situations.
Suppose we have a variable
let value = undefined
.If you use it on an input element with two-way binding
<input bind:value />
, the value is not set (this is the correct behavior, it got fixed in #3430).If you use it on an input element like this:
<input {value} />
, the input elements value property is set to the string 'undefined' (not the attribute).If you use it on any other element, like:
<option {value} />
, the value attribute is set to "undefined".To Reproduce
https://svelte.dev/repl/9a8cf877df9a47948eb0cd3b04ea8372?version=3.19.1
Expected behavior
I think the
value
attribute (without two-way binding) should behave like thedisabled
attribute in the repl.Severity
low
Additional context
You can get around it with
<input value={value || ''} />
The text was updated successfully, but these errors were encountered: