-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Description
Describe the problem
I want to run some code in a component in children
, even if the snippet is conditionally rendered. The use case I have in mind is debugging and meta-programming related.
Describe the proposed solution
Set using <svelte:options>
, a component's <script>
always runs when the component is used in the markup and not in a comment, even if the component is otherwise not rendered.
Alternatives considered
Also set using <svelte:options>
, a component that is unaffected by {#if}, {:else}, {:else if}
and possibly {:then}
of the await-then block. In other words, they are always mounted/called. Leaning towards the proposed solution, because this alternative affects rendering of children components and elements, while the proposed solution is more modular.
Importance
would make my life easier
Additional Information
For example when there is {#if a()} ... {#if b()} ... {/if}{/if}
then the solution should allow such component <script>
in the inner {#if b()}
to run even if the branch is not rendered.