- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 222
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
HTMLInput valueAsNumber
with value = 0 returns NaN
#729
Comments
valueAsNumber
with 0 returns NaNvalueAsNumber
with value = 0 returns NaN
Maybe the code should be adjusted to: return parseFloat(this.value);
|
@MiroslavPetrik Hello, regarding the |
that is example from my codebase. form-atoms/field@aab4481#diff-10a9941191519d185e1921cf27111ad8e4dd0522fd591f11857ec42035a13818R55 It points out that there is number literal -- I was not sure, whether its not bug to just fire event with number value, e.g. even real browsers have string values on number inputs... put other way, the |
The value of input seems to only accept strings
However, if the input type is number, should it also accept number type values? 😕 |
Ok, I get it, so it's not a bug. |
It certainly is a pitfall. Maybe not bug in strict sense with regards to html spec. I would still fix it, my reasons:
|
Agree, type judgment is performed when setting the value, or the value is converted to a string by default. |
#729@patch: Convert input value to string.
Thanks for reporting @MiroslavPetrik! 🙂 Big thanks to @btea for providing with a fix ⭐ You can read more about the release here: Please re-open if the fix did not solve the entire issue. |
Just installed and it works. Thanks. |
Describe the bug
Changing input value to 0 (number literal), and reading it back with
valueAsNumber
returnsNaN
.To Reproduce
Steps to reproduce the behavior:
Expected behavior
For input value 0, the
valueAsNumber
should return 0.Additional context
As workarround, I set the string value in test instead:
valueAsDate
should similarly work with 0The text was updated successfully, but these errors were encountered: