-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Svelte 5: reactive date may be not reactive in the markup #10629
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
Comments
This would work when explicitly calling Svelte uses the internal function |
I'd say this works as expected given the inner rules of the system, even if it's confusing. Doing static analysis to see that Maybe calling |
Yeah I think I'd be in favor of documenting that this is how this works and then moving on. Doing static analysis sounds bad (this is supposed to just be a blessed implementation of something users could also do themselves) and adding |
How is it that the (in my opinion) most important use-case for dates works though? <div>non-reactive: {date}</div>
<div>this works: {format(date)}</div> It doesn't call a method on |
What does the |
Both work: function format1(d) {
return '' + d;
}
function format2(d) {
return '' + d.getSeconds();
} |
Looking at the OG REPL again, you all might have missed the most important bit. This works: <div>reactive: {date}, something else {smth}</div> so it's clearly an issue of tracking reactivity for |
The compiler doesn't consider Also, https://discord.com/channels/457912077277855764/1153350350158450758/1210733443189579896 here I was told this behaviour is a bug. |
in that case, maybe rules is wrong, no? |
A bit more details for those who aren't familiar with Svelte 5 nuances. It seems Dominic considers this a bug, and a variable should be considered reactive when it's initialized with Svelte's reactive class. My opinion is it's very doubtful somebody will print Date as-is: the default date format isn't really convenient for the end user, and dates almost always get a custom format or at least About this issue in general: I think the text node rendering optimisation is an implementation detail, and a programmer shouldn't care about it or even be aware of it. Probably, non-reactive markup expressions should be memorized to provide consistent behaviour across all text nodes. |
You can also manually call |
I feel like we should be using static analysis here to know that the binding itself is from |
That is not quite accurate, I doubt that static analysis is reliable, the value could be imported from somewhere else etc. |
Yeah, let's close this then. The false positives aren't worth it as per #10636. |
Describe the bug
I was told that
<div>{reactiveDate}</div>
being non-reactive is a bug.Reproduction
https://svelte-5-preview.vercel.app/#H4sIAAAAAAAAA12QwWrDMBBEf2URBdskrWy3vTi2odA_6LHpwZXXiaglGWudEoT-vZKTNlDQZXbf7AxybJAjWla9O6Y7haxiL9PEtozOUxT2hCNh0NYss4iT2opZTtTu9Z6kmsxM4OC1IwQPw2wUJBcPn7ETJE-SzskuwAEfkaCPZAMav1dTmpR5-cTzkpePUDxXeR5eku1-cavoGPA7SxGO85rfCui6l6dWG31_DcMKXEzwNY-bK_B_uQVrFNJR6gPgaBFcjPnzBNfnQmQ0GC1GKb4al2bQtOBiq3jhwSK9oTC6t-mqDzedwQaKWNT7dlOAXcc1v1xsw08q08tBYs8qmhf0H_4Hwxyqc4QBAAA=
Logs
No response
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: