Skip to content

Commit

Permalink
fix: allow child element with slot attribute within svelte:element (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
hackape authored Jul 28, 2023
1 parent ce04765 commit 99a3cc9
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/nine-houses-flow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: allow child element with slot attribute within svelte:element
4 changes: 3 additions & 1 deletion packages/svelte/src/compiler/compile/nodes/Element.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default {
html: `
<dynamic-element>
<header slot='header'>header header header</header>
</dynamic-element>
`
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<script>
export let tagName = 'dynamic-element'
</script>

<svelte:element this={tagName}>
<header slot='header'>header header header</header>
</svelte:element>

0 comments on commit 99a3cc9

Please sign in to comment.