diff --git a/.changeset/real-onions-confess.md b/.changeset/real-onions-confess.md new file mode 100644 index 0000000000..25193ace4e --- /dev/null +++ b/.changeset/real-onions-confess.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: ensure logic blocks keep consitent namespacing diff --git a/packages/svelte/src/compiler/phases/3-transform/utils.js b/packages/svelte/src/compiler/phases/3-transform/utils.js index b53a3110bd..bdf4baf038 100644 --- a/packages/svelte/src/compiler/phases/3-transform/utils.js +++ b/packages/svelte/src/compiler/phases/3-transform/utils.js @@ -347,6 +347,14 @@ export function infer_namespace(namespace, parent, nodes) { } } + // If the parent block is a control block, we want to keep the namespace if it's not html + if ( + namespace !== 'html' && + (parent.type === 'EachBlock' || parent.type === 'AwaitBlock' || parent.type === 'KeyBlock') + ) { + return namespace; + } + /** @type {Namespace | null} */ let new_namespace = null;