-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🐛 BUG: Dev server "panic"s and gives scary/unhelpful error when using slots that aren't at the root level #3253
Comments
Dynamically named slots aren't supported, any named slot needs to be given a string rather than a variable like I'm seeing the panic in the reproduction link as well, but it's actually due to the slot |
@tony-sull That's not correct. Even basic examples without a variable break the compiler: <h1>Welcome to <span class="text-gradient">Astro</span></h1>
<ComponentWithSlots>
<div>
<div slot="name">
This breaks the compiler
</div>
<div>
</ComponentWithSlots> |
Sorry @Jutanium, looks like I closed this one too early! Not actually sure what happened the first time, I tested the Stackblitz without the conditional slot and it did actually work somehow, now I'm seeing the same panic again Reopening for further investigation |
So this is definitely not ideal compiler behavior—conditional slots will never work because we need to be able to statically analyze them, but we need to surface a more friendly error.. Unforuntatley reworking the compiler to surface errors instead of panicking will be a pretty large undertaking. Something we need to prioritize. As for the nested slots, how should this work? Slots by definition project their children into certain areas. Would content be plucked out of the parent element? |
@FredKSchott assured me it was a small issue but I had my doubts <3 |
Looks like this has since been fixed: https://stackblitz.com/edit/github-idj9xd-nmsxfu?file=src%2Fpages%2Findex.astro&on=stackblitz |
What version of
astro
are you using?1.0.0-beta.19
Are you using an SSR adapter? If so, which one?
None
What package manager are you using?
yarn
What operating system are you using?
Mac
Describe the Bug
A user might want to dynamically send named slots to an Astro component by looping over an array:
This breaks the compiler because the slots aren't considered at the root of the component. It's similar to this, which also breaks the compiler:
In either case, the compiler literally
panic
s:Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-idj9xd?file=src%2Fpages%2Findex.astro&on=stackblitz
Participation
The text was updated successfully, but these errors were encountered: