handle slot name clashes and invalid names

pull/11334/head
Simon Holthausen 2 years ago
parent 3e2cd3609a
commit d996519105

@ -421,7 +421,7 @@ const template = {
slot_props += `...${state.str.original.substring(/** @type {number} */ (attr.expression.start), attr.expression.end)}, `;
} else if (attr.type === 'Attribute') {
if (attr.name === 'name') {
name = /** @type {any} */ (attr.value)[0].data;
name = state.scope.generate(/** @type {any} */ (attr.value)[0].data);
} else {
const value =
attr.value !== true

@ -3,3 +3,5 @@
{#if foo}
<slot name="foo" {foo} />
{/if}
<slot name="dashed-name" />

@ -1,9 +1,11 @@
<script>
let { children, foo } = $props();
let { children, foo_1, dashed_name } = $props();
</script>
<button>{@render children?.()}</button>
{#if foo}
{@render foo?.({ foo, })}
{/if}
{@render foo_1?.({ foo, })}
{/if}
{@render dashed_name?.()}
Loading…
Cancel
Save