fix: skip certain slot validations for custom elements (#10207)

fixes #10196
pull/10202/head
Simon H 12 months ago committed by GitHub
parent e398047f8f
commit 9f87f059d2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
"svelte": patch
---
fix: skip certain slot validations for custom elements

@ -172,16 +172,21 @@ function validate_slot_attribute(context, attribute) {
error(attribute, 'invalid-slot-attribute');
}
if (owner.type === 'Component' || owner.type === 'SvelteComponent') {
if (
owner.type === 'Component' ||
owner.type === 'SvelteComponent' ||
owner.type === 'SvelteSelf'
) {
if (owner !== context.path.at(-2)) {
error(attribute, 'invalid-slot-placement');
}
}
const name = attribute.value[0].data;
if (context.state.component_slots.has(name)) {
error(attribute, 'duplicate-slot-name', name, owner.name);
}
context.state.component_slots.add(name);
if (name === 'default') {
@ -199,6 +204,7 @@ function validate_slot_attribute(context, attribute) {
error(node, 'invalid-default-slot-content');
}
}
}
} else {
error(attribute, 'invalid-slot-placement');
}

@ -2,6 +2,12 @@
import Nested from './irrelevant';
</script>
<!-- allowed in custom elements -->
<c-e>
<c-e-item slot="allowed"></c-e-item>
<c-e-item slot="allowed"></c-e-item>
</c-e>
<Nested>
<p slot="foo">{value}</p>
<p slot="foo">{value}</p>

Loading…
Cancel
Save