fix: allow child element with slot attribute within svelte:element (#9038)

fix #9018
pull/9037/head
hackape 12 months ago committed by GitHub
parent ce047651e5
commit 99a3cc93b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: allow child element with slot attribute within svelte:element

@ -1413,7 +1413,9 @@ const regex_minus_sign = /-/;
function within_custom_element(parent) {
while (parent) {
if (parent.type === 'InlineComponent') return false;
if (parent.type === 'Element' && regex_minus_sign.test(parent.name)) return true;
if (parent.type === 'Element') {
if (regex_minus_sign.test(parent.name) || parent.is_dynamic_element) return true;
}
parent = parent.parent;
}
return false;

@ -0,0 +1,7 @@
export default {
html: `
<dynamic-element>
<header slot='header'>header header header</header>
</dynamic-element>
`
};

@ -0,0 +1,7 @@
<script>
export let tagName = 'dynamic-element'
</script>
<svelte:element this={tagName}>
<header slot='header'>header header header</header>
</svelte:element>
Loading…
Cancel
Save