-
-
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
bind:valueAsDate #3527
bind:valueAsDate #3527
Conversation
* (breaking change) changes the current `bind:value` behavior that returns a date string of `yyyy-mm-dd` so that it will return a `Date` value instead.
…ncasey/svelte into colincasey-proposal/bind_value_as_date
Man, SSR was a rabbit hole, especially |
Codecov Report
@@ Coverage Diff @@
## master #3527 +/- ##
=======================================
Coverage 50.25% 50.25%
=======================================
Files 1 1
Lines 197 197
=======================================
Hits 99 99
Misses 98 98 Continue to review full report at Codecov.
|
I just had an idea of the syntax Maybe we could also add a syntax for binding a numeric value as a string ( |
@Conduitry I think that syntax makes a lot of sense. It could be a good precedent for |
Yeah, I like the |
By this do you mean that the default is always to bind as a string, and you use a |
The opposite, actually — I'd like to continue using If we went the other way, always treating |
My understanding for what happened with I don't have a strong opinion about the syntax, but - unless I'm misunderstanding something - it seems more future proof to default to strings. |
Or — galaxy brain — we could treat the new input type's behaviour as a bug, and fix it in a patch. Realistically though, we'd get months of warning about any new input type, and the semantics would be understood long before it was viable for use in production, so as long as Svelte was still being maintained if and when that happened we should be able to get ahead of it and avoid any breaking changes. If it happened and Svelte wasn't still being developed, then we wouldn't need to worry about breaking changes anyway. |
Fair, but it does mean that we'd have to catch now (or at v4, or whatever) all of the existing ones that we're likely to want to handle specially. Are there other datepicker-y things besides If you're confident that we can make a number of correct decisions all at once, then I agree that defaulting to conversion is probably more convenient for more people - but it just seems risky to me. |
Looking at the full list of input types on MDN, I only see two others that would make sense to handle. There's |
That was my conclusion also — I think we're covered. There are some other inputs that expose a File inputs are already handled: https://svelte.dev/repl/387bf1bbbd134d0193df33ddf712fd40?version=3.14.1 I'll close this and #3494 and open a new issue for the modifiers. |
This is a branch off, and alternative to, #3494. Out of respect for semver I think we have to treat this as a new binding, rather than changing the behaviour of the existing
bind:value
. In v4 we can revisit this area — I'll open a separate issue for that.JSDOM doesn't handle this case, so the tests are incomplete pending jsdom/jsdom#2658.
Marked as draft because it doesn't yet handle the SSR case.