hperrin / svelte-material-ui

Svelte Material UI Components
https://sveltematerialui.com/
Apache License 2.0
3.28k stars 288 forks source link

Fix `NaN` in `toNumber` #541

Closed DetachHead closed 1 year ago

DetachHead commented 1 year ago

i'm not sure why it was creating a new Number and setting a length property on it. my understanding is that the primitive wrapper objects (Number, String, etc.) should be avoided.

in my case it was causing problems in my code because i was using typeof value === 'number' to check if a value was a number, when it was actually an 'object'

hperrin commented 1 year ago

This code came from this commit: https://github.com/hperrin/svelte-material-ui/commit/939543f2a824deac29e77a912cb26cbe0dd0f2fb

Let me figure out if this change will cause any issues.

hperrin commented 1 year ago

It does cause the floating label to stay floating when the input is empty.

hperrin commented 1 year ago

I was able to fix that problem by checking explicitly for NaN in the floating label check.

Thanks for the fix!