diff --git a/.changeset/nine-houses-flow.md b/.changeset/nine-houses-flow.md new file mode 100644 index 000000000000..d3783c6c1cc4 --- /dev/null +++ b/.changeset/nine-houses-flow.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: allow child element with slot attribute within svelte:element diff --git a/packages/svelte/src/compiler/compile/nodes/Element.js b/packages/svelte/src/compiler/compile/nodes/Element.js index f770cb190d84..654c2c48f08c 100644 --- a/packages/svelte/src/compiler/compile/nodes/Element.js +++ b/packages/svelte/src/compiler/compile/nodes/Element.js @@ -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; diff --git a/packages/svelte/test/runtime/samples/slot-in-dynamic-element/_config.js b/packages/svelte/test/runtime/samples/slot-in-dynamic-element/_config.js new file mode 100644 index 000000000000..589e57d78e04 --- /dev/null +++ b/packages/svelte/test/runtime/samples/slot-in-dynamic-element/_config.js @@ -0,0 +1,7 @@ +export default { + html: ` + +
header header header
+
+ ` +}; diff --git a/packages/svelte/test/runtime/samples/slot-in-dynamic-element/main.svelte b/packages/svelte/test/runtime/samples/slot-in-dynamic-element/main.svelte new file mode 100644 index 000000000000..38d7cd233e80 --- /dev/null +++ b/packages/svelte/test/runtime/samples/slot-in-dynamic-element/main.svelte @@ -0,0 +1,7 @@ + + + +
header header header
+
\ No newline at end of file