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
<!-- ForwardCard.svelte -->
<script>
importCardfrom'./Card.svelte'exportlet message ='custom message'
</script>
<Card {message}>
<divslot="title">This is a ForwardCard.svelte</div>
<!-- if the slot is not specified, it should display the Card.svelte fallback slot -->
<slotname="message"slot="message" {message}/>
</Card>
<!-- App.svelte --><!-- see question at SO: https://stackoverflow.com/q/77476736/47633 -->
<script>
importCardfrom'./Card.svelte'importForwardCardfrom'./ForwardCard.svelte'
</script>
<Cardmessage='Card with fallback slot!' /> <!-- slot with fallback content: OK! -->
<Cardmessage='Card with custom slot'> <!-- slot with custom content: OK! -->
<divslot="message"let:message>custom slot: {message}</div>
</Card>
<ForwardCardmessage='ForwardCard with fallback slot!' /> <!-- forwarded slot with fallback content: WRONG!!! -->
<div>ERROR: MISSING "fallback slot: ForwardCard with default fallback!"</div>
<hr />
<ForwardCardmessage='ForwardCard with custom slot' > <!-- forwarded slot with custom content: OK! -->
<divslot="message"let:message>custom slot: {message}</div>
</ForwardCard>
output:
This is a Card.svelte
fallback slot: Card with fallback slot!
This is a Card.svelte
custom slot: Card with custom slot
This is a ForwardCard.svelte
ERROR: MISSING "fallback slot: ForwardCard with default fallback!"
This is a ForwardCard.svelte
custom slot: ForwardCard with custom slot
Note: I also tried with Svelte 5 snippets and it works ok (great!!!)
note: it seems to me like this line <slot name="message" slot="message" {message}/> is sending an empty slot, instead of no slot at all, and that's why the fallback is not being called. perhaps it's not a bug, but it's just that I couldn't find a way to forward no slot.
In other words, When ForwardCard doesn't receive any message slot, it shouldn't send any message slot to Card, instead of sending an empty slot, like I suspect it's doing right now.
There are many such edge cases and small gotchas with the current slot system. Closing because snippets replace slots with a more predictable and flexible solution.
Describe the bug
I define a Card.svelte component with a
message
slot, which has a default fallback content.I can render the
Card
component with the fallback slot and also override it correctly ==> OKI then define a ForwardCard.svelte which calls Card.svelte, customizing it's titlle, and passes on the
message
slot.ForwardCard slot can be overriden, but if the slot is not specified IT WON'T fallback to use the default of the parent component, Card.svelte.
svelte repl reproducing the issue: link
output:
Note: I also tried with Svelte 5 snippets and it works ok (great!!!)
svelte 5 repl: link
Reproduction
svelte 4 repl with error
svelte 5 repl working OK
Logs
No response
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: