Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Jul 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -1414,7 +1414,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>