-
Notifications
You must be signed in to change notification settings - Fork 8
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
handle valueAsDate to keep time for unchanged date #539
Comments
Interesting issue, where does canjs currently do property special casing? I guess it's probably here... https://github.com/canjs/can-attribute-observable/blob/master/behaviors.js |
Yes, that's where it is done. |
I ran into this while updating the guides and had a somewhat different recommendation. Rather than handling one scenario, i.e keeping the time from being dropped from the Date so long as a user doesn't make a change via the input, we should instead let the browser drop the time and warn developers about this behavior. That way, the developer is fully aware of the consequences of using this binding, rather than leaving a potential pitfall when a user modifies a date that already has a time via the input, unexpectedly dropping the time. So, when a developer binds two-way or parent-to-child to Similarly, when a developer binds two-way or parent-to-child to |
My interest in this issue was due to my belief it was the cause of a "two-way binding changing or converting its value when set" warning when two way binding to This is because when setting A CodePen showing I suspect we'll have to add smarter equality checking for Objects to the code here: https://github.com/canjs/can-bind/blob/fc2f0cec958c224165857c11b0eae06152b7fedf/can-bind.js#L401 |
If you set an input with
valueAsDate
and read the value back you will get a Date object but it will no longer have the same time as the date object that you gave it. It currently doesn't supportdatetime
onlydate
ortime
.Example - https://codepen.io/mattchewone-the-looper/pen/EBMRXR?editors=0010
Spec - https://html.spec.whatwg.org/multipage/input.html#concept-input-apply
We could handle
valueAsDate
to keep the same date object if un-modified so that you don't lose thetime
aspect.The text was updated successfully, but these errors were encountered: