diff --git a/.changeset/tangy-keys-drop.md b/.changeset/tangy-keys-drop.md new file mode 100644 index 0000000000..38f0c10543 --- /dev/null +++ b/.changeset/tangy-keys-drop.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: ignore declaration tags for animation directive diff --git a/packages/svelte/src/compiler/phases/2-analyze/visitors/shared/element.js b/packages/svelte/src/compiler/phases/2-analyze/visitors/shared/element.js index 725a4aded8..ff02dee02a 100644 --- a/packages/svelte/src/compiler/phases/2-analyze/visitors/shared/element.js +++ b/packages/svelte/src/compiler/phases/2-analyze/visitors/shared/element.js @@ -100,6 +100,7 @@ export function validate_element(node, context) { (n) => n.type !== 'Comment' && n.type !== 'ConstTag' && + n.type !== 'DeclarationTag' && (n.type !== 'Text' || n.data.trim() !== '') ).length > 1 ) { diff --git a/packages/svelte/tests/validator/samples/animation-each-with-declaration-tag/errors.json b/packages/svelte/tests/validator/samples/animation-each-with-declaration-tag/errors.json new file mode 100644 index 0000000000..fe51488c70 --- /dev/null +++ b/packages/svelte/tests/validator/samples/animation-each-with-declaration-tag/errors.json @@ -0,0 +1 @@ +[] diff --git a/packages/svelte/tests/validator/samples/animation-each-with-declaration-tag/input.svelte b/packages/svelte/tests/validator/samples/animation-each-with-declaration-tag/input.svelte new file mode 100644 index 0000000000..680efa7eed --- /dev/null +++ b/packages/svelte/tests/validator/samples/animation-each-with-declaration-tag/input.svelte @@ -0,0 +1,10 @@ + + +
+ {#each [] as n (n)} + {const a = n} +
+ {/each} +