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
When using a range input in a SvelteKit app and binding its value to a state variable that starts with a value outside the defined range (min, max), the variable is coerced into the range but unexpectedly converted to a string.
This issue appears to be specific to SvelteKit.
Expected Behavior
The variable bound to the range input should always retain its numeric type, even when its initial value is coerced into the range.
Reproduction
Reproducing example:
<script>
let myNumber = $state(1.5);
$inspect(myNumber);
</script>
<input bind:value={myNumber} type="range" min={0} max={1} step={0.01}>
{#if typeof myNumber == "number"}
<pre>{myNumber.toFixed(2)}</pre>
{:else}
<pre>My number is not a number! {myNumber}</pre>
{/if}
Describe the bug
When using a range input in a SvelteKit app and binding its value to a state variable that starts with a value outside the defined range (min, max), the variable is coerced into the range but unexpectedly converted to a string.
This issue appears to be specific to SvelteKit.
Expected Behavior
The variable bound to the range input should always retain its numeric type, even when its initial value is coerced into the range.
Reproduction
Reproducing example:
https://stackblitz.com/edit/sveltejs-kit-template-default-9wzchg?file=src%2Froutes%2F%2Bpage.svelte
When the page loads, myNumber has a string type, and the following message is displayed:
My number is not a number! 1
is displayed.Logs
No response
System Info
Severity
annoyance
Additional Information
No response
The text was updated successfully, but these errors were encountered: