🐛 BUG: astro's compiler struggles when using `slot` attribute outside of custom components
What version of astro are you using?
0.25.4
What package manager are you using?
npm
What operating system are you using?
Linux
Describe the Bug
When using slots outside of custom components compiler goes into ashes
The exemple below is getting UnhandledPromiseRejectionWarning: Error: EBADF: bad file descriptor, write
i also gotten panic: Element with a slot='...' attribute must be a child of a component or a descendant of a custom element on my machine
may causes issues when trying an implementation of many OpenUI's components like <selectmenu/>
Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-xow7rt?file=src%2Fpages%2Findex.astro&on=stackblitz
Participation
- [ ] I am willing to submit a pull request for this issue.
Yep, this is a pain! This is something I've been hoping to fix for a while—I have a few ideas on how we could address this with minimal disruption.
Update: we'll have to chat about the best way forward here as a team! But it's a high priority to have an officially documented way to do this.
My initial suggestion would be borrowing our existing is:inline syntax (which applies to script or style) for native slot. Not entirely ergonomic, but better than silently changing behavior.
There's a workaround mentioned in https://github.com/withastro/astro/issues/2509, but I'll keep this as the issue to track this.
This particular issue was fixed in https://github.com/withastro/compiler/pull/442 and works in the latest release candidate. https://stackblitz.com/edit/github-xow7rt-yogycs?file=src%2Fpages%2Findex.astro&on=stackblitz.
There are still cases where slot doesn't work like everyone expects, so I'll leave this open until those are addressed.