-
-
Notifications
You must be signed in to change notification settings - Fork 147
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
CheckedObserver truthy values and matcher coercion #92
Comments
The looser comparison seems like it might be the way to go, rather than coercing values. |
Can you elaborate? You mean |
I meant this |
Yeah it's two separate ones. The primitive only responds to boolean at the moment. But since The array is a bit broader because it simply looks for equality with the |
We should get @jdanyow to provide feedback on this. I thought the |
Yep just ran into this with the unit tests. The model property doesn't have this problem so I would only apply the coercion logic for the For example:
etc.. |
Just walked through the comments, I'm not sure how to look at this. Though altering behavior of |
It's the other way around. Currently it's not predictable because the DOM will coerce values but the observer won't. I'm simply suggesting we should make the observer do the same coercions that the DOM does, so that it becomes predictable :) |
Is there any reason we have to use the |
Implicitly converting the value types could be double edged, we better wait until the first request comes to have some concrete case based ideas. |
In fixing the CheckedObserver tests / logic for the SubscriberCollection PR I noticed a few things that might be up for improvement, but in order to keep that PR clean I'm adding some notes here instead.
If you set the
value
property of acheckbox
to a non-string primitive and have thechecked
property bound to an array with that same non-string primitive, the corresponding input element would not be checked because thevalue
property of a checkbox is always coerced to a string. Users might consider this unintuitive.In the default matcher function:
We could coerce the value (a, which comes from the VM) to strings:
This would make the behavior consistent with how HTML behaves.
The performance impact here would be negligible since adding an empty string to a string is usually optimized by browser jit.
Furthermore, for similar reasons we could consider being more loose with the
checked
property comparison. Booleans have a tendency to get coerced to strings somewhere along the flow of binding.So we might want to change this:
To this:
@EisenbergEffect @bigopon
The text was updated successfully, but these errors were encountered: