svelte icon indicating copy to clipboard operation
svelte copied to clipboard

undefined slot props when component has slot attr

Open ryu-man opened this issue 5 years ago • 5 comments

Hello guys, I have encountered a problem with slot props, the scenario of the issue is: When component A ( which have slot element and export slot props ) inserted in the named slot of component B ( have both named and default slot elements ) using the slot property and try accessing component A's slot props will results in "undefined" values, however, everything works fine if the component used as default slot

I have created a reproduction of the issue in REPL, please check out this link: https://svelte.dev/repl/c1284a4af1eb48768a2e66ece04abe8d?version=3.35.0

ryu-man avatar Mar 11 '21 23:03 ryu-man

@meiseayoung <svelte:fragment slot="name" let:prop> is also working fine, the issue appears only when using component as a named slot

ryu-man avatar Mar 12 '21 10:03 ryu-man

A component that has a slot attribute will not provide his slot props, but rather you will access the slot props provided by the direct parent

ryu-man avatar Apr 14 '21 21:04 ryu-man

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Oct 11 '21 22:10 stale[bot]

I have run into this situation this week as well.

Fortunately it can be worked around by wrapping the component with some element (i.e. 'div').

If this is not a bug however it is surprising and at best it's not properly documented.

saabi avatar Jun 11 '23 22:06 saabi