Skip to content
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: Conditional named slots break the compiler #383

Closed
1 task
Jutanium opened this issue May 2, 2022 · 2 comments · Fixed by #447
Closed
1 task

🐛 BUG: Conditional named slots break the compiler #383

Jutanium opened this issue May 2, 2022 · 2 comments · Fixed by #447

Comments

@Jutanium
Copy link

Jutanium commented May 2, 2022

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

Any way of including named slots with JSX interpolation breaks the compiler.

<TestAstro>
	{isTrue && <p slot="name">Dan</p>}
</TestAstro>

Even though this is indeed the direct child of a component, the compiler enters panic mode with the message:
panic: Element with a slot='...' attribute must be a child of a component or a descendant of a custom element

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-idj9xd-ghiwxt?file=src/pages/index.astro

Participation

  • I am willing to submit a pull request for this issue.
@natemoo-re
Copy link
Member

Going to move this one to the compiler repo. I think we might be able to support this, but I'll have to do some experiments.

Just FYI, from the compiler's perspective the slot is a child of the expression node, so it isn't at the root of the component. That's why this error is happening.

See also my comment about friendly error messages here
withastro/astro#3253 (comment)

@natemoo-re natemoo-re transferred this issue from withastro/astro May 10, 2022
@natemoo-re
Copy link
Member

Going to reopen this one! It doesn't throw anymore but it's still not handling the slot transformation properly.

https://stackblitz.com/edit/github-ujjuhe?file=src%2Fcomponents%2FCounter.tsx,src%2Fpages%2Findex.astro

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants