You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
No warning is issued for applying a bind: directive on the value prop, without a matching $bindable() declaration in the $props().
No warning is issued for using bind:value and bind:group simultaneously on the input.
This can lead to inconsistencies and erroneous types of the bound state, where the state of selected (a number, in the example below) actually becomes a string.
Reproduction
<!-- Input.svelte -->
<script>
let { value, group =$bindable() } =$props();
</script>
<inputtype="radio"bind:groupbind:value />
The text was updated successfully, but these errors were encountered:
jrmoynihan
changed the title
Svelte 5: Add warning to compiler when using bind:value
Svelte 5: Add warning to compiler when using bind:value incorrectly
May 19, 2024
jrmoynihan
changed the title
Svelte 5: Add warning to compiler when using bind:value incorrectly
Svelte 5: Add warning to compiler when using bind:value incorrectly
May 19, 2024
It is valid to not declare the value as bindable because it's valid for the property to get out of sync with its parent. Therefore closing.
@dummdidumm Can you give a use-case/example where the developer intent is to bind the value, but it is still valid to let the value get out of sync with its parent? This seems to defeat the purpose of "binding" if it's not "bound".
The second case is even more baffling. How can you reliably know the result of an update operation with two different bind directives on the same element. Isn't that a clear race-condition issue that should be avoided or warned about?
Describe the bug
In the code below, there are two issues:
bind:
directive on thevalue
prop, without a matching$bindable()
declaration in the$props()
.bind:value
andbind:group
simultaneously on the input.This can lead to inconsistencies and erroneous types of the bound state, where the state of
selected
(a number, in the example below) actually becomes a string.Reproduction
Svelte 5 REPL reproduction
Logs
No response
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: