I have a bug (?) where the contents of a slot are being evaluated even when the slot is never used (rendered).
I have a When.astro similar to the astro-control package:
---
type Props = {
[key: string]: unknown;
};
const propValues = Object.values(Astro.props);
const present = propValues.every(Boolean);
const render = present ? "default" : "else";
const html = Astro.slots.has(render) && (await Astro.slots.render(render));
---
<Fragment set:html={html} />
Using it like this produces an error:
---
const value = undefined;
---
<When {value}>
<h2>{value!.test}</h2>
<h2 slot="else">No Value</h2>
</When>
Cannot read properties of undefined (reading 'test')
This shouldn't happen, and I believe it started happening recently. If I remove the <h2>{value!.test}</h2> the No Value renders, so it should never evaluate the expression in the default slot if I'm not mistaken.
Is this an issue on my part? Am I missing something?