-
-
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
Binding without values are change to string undefined #249
Comments
I think the problem is this code in output: addEventListener( input, 'input', inputChangeHandler );
input.value = root.name; I think it should be: addEventListener( input, 'input', inputChangeHandler );
input.value = root.name || ""; |
and also this line, when updating input value: if ( !input_updating ) input.value = root.name || ""; |
or better input.value = typeof root.name == 'undefiend' ? "" : root.name; so it will work when value is number 0 or boolean false. it will be converted to string "0" and "false" which is fine I think. |
You like to pull a request? |
I can take a look at the code and create PR if I'll found the solution to the problem in the code. |
Created PR. |
Thanks for the PR @jcubic. I'm a little hesitant to go down this road — while it seems more convenient in this case, I worry that it's not a good general solution, since it doesn't necessarily translate well to other forms of two-way binding (#10), and can easily mask errors (e.g. if I think the best way to handle this case is to have a default value for |
I can get behind that. It's certainly different than Ractive, but it forces a sort of declarative/specific measure on variable values—i.e., have variables respond according to actual definition. Please do add a console warning or something to that effect for ease of development, however. |
throw error in dev mode for missing bound properties (#249)
Development warnings are now implemented — if a property isn't declared for a binding, and the compiler is running with |
In current repl if you don't provide value for binding the value (in input tag) is undefiend and coerced to string so its value is "undefined" demo
if the value is undefiend it should be empty string in input, like in this demo
The text was updated successfully, but these errors were encountered: