Skip to content

Commit 99a3cc9

Browse files
authored
fix: allow child element with slot attribute within svelte:element (#9038)
fix #9018
1 parent ce04765 commit 99a3cc9

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

.changeset/nine-houses-flow.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: allow child element with slot attribute within svelte:element

packages/svelte/src/compiler/compile/nodes/Element.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1413,7 +1413,9 @@ const regex_minus_sign = /-/;
14131413
function within_custom_element(parent) {
14141414
while (parent) {
14151415
if (parent.type === 'InlineComponent') return false;
1416-
if (parent.type === 'Element' && regex_minus_sign.test(parent.name)) return true;
1416+
if (parent.type === 'Element') {
1417+
if (regex_minus_sign.test(parent.name) || parent.is_dynamic_element) return true;
1418+
}
14171419
parent = parent.parent;
14181420
}
14191421
return false;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export default {
2+
html: `
3+
<dynamic-element>
4+
<header slot='header'>header header header</header>
5+
</dynamic-element>
6+
`
7+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<script>
2+
export let tagName = 'dynamic-element'
3+
</script>
4+
5+
<svelte:element this={tagName}>
6+
<header slot='header'>header header header</header>
7+
</svelte:element>

0 commit comments

Comments
 (0)