You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#snippet is a feature i’ve really wanted, great news! Related to this feature, is that i’ve found myself defining many locally used objects inside the global script tag in a +page, which could just as well been defined locally in a tag and only be used there. I have no idea about the complications of this, but may this be considered in some version of Svelte?
Non-top-level <script> tags aren't something we want to change the behavior of, because those are currently used for injecting that literal <script> tag at that point in the DOM, as an escape hatch for various situations.
Yes, i am aware of {#const ... }, but the purpose of this is only to make a shorthand calculation or something similar, right? When defining a {#const ... } variable locally, it is dependent on other variables, and is non-editable. I would like an editable locally defined variable. (I have added a REPL example in my original comment).
Describe the problem
#snippet is a feature i’ve really wanted, great news! Related to this feature, is that i’ve found myself defining many locally used objects inside the global script tag in a +page, which could just as well been defined locally in a tag and only be used there. I have no idea about the complications of this, but may this be considered in some version of Svelte?
Describe the proposed solution
It would be awesome to define local script tags or just local variables, either within a tag in a +page or a #snippet, or both. Here is a small example: https://svelte.dev/repl/8492f743da224435b860620f74096991?version=4.2.3
Alternatives considered
Components can be used to solve this, but I think these would not fit these cases properly.
Importance
nice to have
The text was updated successfully, but these errors were encountered: