Closed
Description
Describe the bug
I am trying to create a form validator, and I encountered a bug when it does not change the $state of values
on the first keypress inside <CustomInput/>
This is smallest code that reproduce that bug:
<script>
import CustomInput from './Input.svelte';
class Form {
values = $state({name:''});
errors = $state({});
getProps(name) {
return {
oninput: (e) => {
this.errors[name] = "something"
},
error: this.errors[name],
};
}
}
let form = new Form();
</script>
<CustomInput bind:value={form.values.name} {...form.getProps('name')} />
<!-- Input.svelte -->
<script >
let {value = $bindable(), error, ...rest} = $props();
</script>
<input bind:value {...rest} />
Things I found:
- I don't encouter this bug inside firefox.
- It works when I move function
getProps()
outsideForm
class.
Reproduction
Logs
No response
System Info
System:
OS: Linux 6.7 Fedora Linux 39 (Workstation Edition)
CPU: (8) x64 Intel(R) Core(TM) i5-8300H CPU @ 2.30GHz
Memory: 5.38 GB / 15.48 GB
Container: Yes
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.10.0 - ~/.nvm/versions/node/v20.10.0/bin/node
npm: 10.2.3 - ~/.nvm/versions/node/v20.10.0/bin/npm
Browsers:
Chrome: 123.0.6312.86
npmPackages:
svelte: 5.0.0-next.102 => 5.0.0-next.102
Severity
annoyance
Metadata
Metadata
Assignees
Labels
No labels