lambda-packages icon indicating copy to clipboard operation
lambda-packages copied to clipboard

🐛 BUG: astro's compiler struggles when using `slot` attribute outside of custom components

Open Chrissdroid opened this issue 3 years ago • 3 comments

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.

Chrissdroid avatar Mar 29 '22 13:03 Chrissdroid

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.

natemoo-re avatar Apr 02 '22 18:04 natemoo-re

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.

natemoo-re avatar May 10 '22 22:05 natemoo-re

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.

natemoo-re avatar Aug 05 '22 15:08 natemoo-re