-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Astro.slot.render() with arguments does not work with Fragment #6683
Comments
Thanks! |
I will be looking this bug. |
this bug should be closed |
@JerryWu1234 So far this bug has only been partially fixed, PR #6832 fixed this case: <Fragment slot="name">
Text
</Fragment> But, this case has not been fixed: <Fragment slot="name">
{arg => <span>{arg}</span>}
</Fragment> |
${renderComponent($$result, "Slot", $$Slot, {}, { "name": ($$result2) => renderTemplate`${renderComponent($$result2, "Fragment", Fragment, { "slot": "name" }, { "default": ($$result3) => renderTemplate`${(arg) => renderTemplate`<p>${arg}</p>`}` })}` })} Because of the nested element, there is a workaround that uses the original tags (‘div’, ‘span’). such as <div slot="name">
{arg => <span>{arg}</span>}
</div> |
I think that it requires a lot of work if we want to fix this bug. Perhaps my idea is not a good one. So please share your idea if you have any idea to fix this bug. this bug is derived from this line
|
Thanks for looking into this one @JerryWu1234! I agree that this would be awesome to fix but it will take quite a bit of work. One possible idea is to adjust our compiler output so that we generate an optimized statement for cases like this. That's probably the cleanest approach I can think of, since we'd need to deal with scope tracking across async boundaries otherwise. |
For my own future reference, investigating this was Linear ticket |
@BryceRussell What is the use case for |
@lilnasy For me, |
Yeah, that's fair. To clarify, the tag name "frag" is not special, any plain HTML tag works and they are documented with named slots. We don't document |
Ya I was just using |
In this case, the function is the default slot of the Related: #7610 (comment) Closing as a |
This used to work (using a psuedo |
I'm still looking through to see if |
I'm re-opening until we know whether/when the behavior changed. |
@lilnasy I was doing some testing on this and I figured out that it was breaking on my end because I was using tags with dashes
I think it is safe to close this issue, thanks! |
What version of
astro
are you using?2.1.7
Are you using an SSR adapter? If so, which one?
None
What package manager are you using?
pnpm
What operating system are you using?
Windows
What browser are you using?
Firefox
Describe the Bug
When
Astro.slots.render()
is called with arguments it does not handle<Fragment>
s correctly and throws an error.Does NOT Work:
Works:
This is the line that throws the error: https://github.com/withastro/astro/blob/main/packages/astro/src/core/render/result.ts#L106
It looks like the
<Fragment>
is being rendered into HTML before it can be rendered with the arguments fromAstro.slots.render()
Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-ucqonn?file=src/pages/index.astro
Participation
The text was updated successfully, but these errors were encountered: