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
Describe the bug
Let's say we use variable with type string, on use bind from input type range or number on that value. It's forced to retype to number, as You can see in Repl, but somethimes, You don't want to automatically force retype of variable if it's value is changed by bind from input type number or range, that is now forced, see
If that's not possible, we recommend creating a small repo that illustrates the problem.
Reproductions should be small, self-contained, correct examples – http://sscce.org.
Occasionally, this won't be possible, and that's fine – we still appreciate you raising the issue. But please understand that Svelte is run by unpaid volunteers in their free time, and issues that follow these instructions will get fixed faster.
Expected behavior
Have ability to change variable from input type number or range with preserve type string in variable
Information about your Svelte project:
Your browser and the version: Chrome and Firefox (newest verrsions)
Your operating system: Ubuntu 20.04
Svelte version: 3.29.4
Rollup
Severity
Medium, You need now to do:
let a = "5" // and use it to bind inputs.
$: a_string = String(a); // and use this in other code, but still there is problem, if a_string is changed from somewhere else.
// if You add another line:
$: a = Number(a_string); // but it will redeclare "a" so You need to use "a_string | 5", but it still not work:
// it will result in `Cyclical dependency detected: a_string → a → a_string (3:1)`
// so there is not easy solution for this.
Additional context
We should propably don't depend on type of input, but on another attribute, that will say, what type we will really want in result, like
<input bindtype="string"> // or any other type
propably for other binds as well
The text was updated successfully, but these errors were encountered:
Mlocik97
changed the title
Don't use forced type conversion on bind, it can cause some mismatched type conversion.
Don't use forced type conversion on bind, it can cause some unsolicited type conversion.
Oct 23, 2020
Describe the bug
Let's say we use variable with type string, on use bind from input type range or number on that value. It's forced to retype to number, as You can see in Repl, but somethimes, You don't want to automatically force retype of variable if it's value is changed by bind from input type number or range, that is now forced, see
svelte/src/compiler/compile/render_dom/wrappers/Element/Binding.ts
Lines 396 to 400 in 229a16d
Logs
(none)
To Reproduce
https://svelte.dev/repl/64ae5620f0bd44adaba952ccfd444493?version=3.29.4
Occasionally, this won't be possible, and that's fine – we still appreciate you raising the issue. But please understand that Svelte is run by unpaid volunteers in their free time, and issues that follow these instructions will get fixed faster.
Expected behavior
Have ability to change variable from input type number or range with preserve type string in variable
Information about your Svelte project:
Your browser and the version: Chrome and Firefox (newest verrsions)
Your operating system: Ubuntu 20.04
Svelte version: 3.29.4
Rollup
Severity
Medium, You need now to do:
Additional context
We should propably don't depend on type of input, but on another attribute, that will say, what type we will really want in result, like
<input bindtype="string"> // or any other type
propably for other binds as well
The text was updated successfully, but these errors were encountered: