compiler icon indicating copy to clipboard operation
compiler copied to clipboard

🐛 BUG: `Astro.slots.render` "function mode" removes the slot wrapper element

Open Jutanium opened this issue 3 years ago • 0 comments

What version of @astrojs/compiler are you using?

1.0.8

What package manager are you using?

npm

What operating system are you using?

Mac

Describe the Bug

Astro.slots.render lets you optionally pass an array of arguments:

const html = (await Astro.slots.render("title", [prefix]));

If the slot has a "function child", the elements of this array will be passed to that function. In the "default" slot case, it works as expected. You'd pass a function like this:

<GimmeDefaultFunctionSlot>{(foo, bar) => (<div>{foo} {bar}</div>)}</GimmeDefaultFunctionSlot>

But in the named slot case, the contents of the slot get rendered, but the slot element itself disappears.

<GimmeFunctionSlot>
	<h1 slot="title">
		{(prefix) => <span>{prefix + "Fuzzy"}</span>}
	</h1>
</GimmeFunctionSlot>

This will render the span, but not the h1.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-m8ymyr?file=src%2Fpages%2Findex.astro

Jutanium avatar Aug 24 '22 20:08 Jutanium