Skip to content

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

@Jutanium

Description

@Jutanium

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions