-
-
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
For input numbers we should use null instead undefined in toNumber #1701
Comments
I don't know what the problem was supposed to have been when this issue was opened (and I also don't know what version it was against. there is no 2.30.1), but in the latest v2 I don't see anything in the console https://v2.svelte.dev/repl?version=2.16.1&gist=4728f0fd73979c92e7c07ec0a7eebb94 |
@Conduitry please reopen. The main idea is you can't return undefined from "input number" because you can't set it back, it's just not valid by the standard. |
I see, anyway return |
Warnings like this:
|
@Conduitry did you see the same warning? |
I see the warning in 3.20.1 - note that the warning doesn't appear in the Svelte console, but the browser console. |
Researched on how vue is handling this case, export function toNumber (val: string): number | string {
const n = parseFloat(val)
return isNaN(n) ? val : n
} we can also set |
This has been changed to use |
Thanks! |
If you return undefined it became the problem for some situations like this (we can't set undefined back):
https://svelte.technology/repl?version=2.30.1&gist=4728f0fd73979c92e7c07ec0a7eebb94
by the standard, the "number input" can contain numbers or empty and empty here is an empty string or null.
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/number
The text was updated successfully, but these errors were encountered: