Open borgius opened 2 years ago
Currently you can't dynamically pass in elements with slot attribute,
so, all of the
{#if left}
<Btn slot="left" text="{left}" />
{/if} {#if right}
<Btn slot="right" text="{right}" />
{/if}
in your example is considered as passed into the default
so, a workaround for this would be
{#if left && !right}
<NavBar {title}>
<Btn slot="left" text="{left}" />
</NavBar>
{:else if !left && right}
<NavBar {title}>
<Btn slot="right" text="{right}" />
</NavBar>
{:else if left && right}
<NavBar {title}>
<Btn slot="left" text="{left}" />
<Btn slot="right" text="{right}" />
</NavBar>
{:else if !left && !right}
<NavBar {title} />
{/if}
Thank you for explanation and workaround, but workaround looks complicated, and will be more complicated with more props... So, may be we can convert it to feature request? That behavior looks logical and will be really useful for multiple scenarios. Thank you!
Describe the bug
If we put named slot in {#if} block on parent component, child will not receive the named slot, but only default slot. Please check NavBar.svelte $$slots Example:
App.svelte
```svelteHeader.svelte
```svelteNavBar.svelte
```svelte {JSON.stringify($$slots)} {#if $$slots.left} [Left slot]{title}
{/if} {#if $$slots.right} [Right slot]Btn.svelte
```svelte [{text}] ```Reproduction
https://svelte.dev/repl/c0de4395f6ad4f7c9093a660225e7110?version=3.48.0
Logs
No response
System Info
Severity
annoyance