astro
astro copied to clipboard
🐛 BUG: dynamic tag name wrapping nested named slots causes tag to be closed immediately
What version of astro
are you using?
1.0.0-beta.18
Are you using an SSR adapter? If so, which one?
no
What package manager are you using?
npm
What operating system are you using?
Ubuntu Linux (within Windows with WSL)
Describe the Bug
When using a dynamic tag name in an Astro component, that dynamic tag seems to be getting auto-closed if it contains nested named slots
stackblitz example: https://stackblitz.com/edit/github-s8gpab?file=src%2Fcomponents%2FCardBroken.astro&on=stackblitz
notice how the BrokenCard.astro component results in an <a>
being generated with it's closing </a>
immediately following the opening tag (and the card's content following the closing tag, except the one comment which for some reason does seem to be getting placed within the <a>
?):
Compare to the two working examples (removing either the dynamic tag name, or the nested named slot) where the <a>
wraps the card's content as expected:
Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-s8gpab?file=src%2Fcomponents%2FCardBroken.astro&on=stackblitz
Participation
- [X] I am willing to submit a pull request for this issue.
I moved this to the compiler repo, but this doesn't look like a compiler issue. I'm really struggling to understand what you expect this code to do. What is the desired output here? My gut reaction is that nested slots don't make a lot of sense—where are these slots supposed to be projected?
Thanks for checking this out @natemoo-re !
my thinking is that if content for the outer slot is supplied, that will be used (replacing the inner slot). if content for the inner slot is supplied, then that content would appear (surrounded by whatever other default content for the outer slot is defined in the template). hope that makes sense?
afaict this seems to be the behavior exhibited by the nested non-named slot, and the nested named slot in the case that there isn't a dynamic tag name, so it's not clear to me why having the dynamic tag name should change the behavior of the slots? but perhaps i'm misunderstanding something?