From a2f8ca856cf240f49a1b7e349ccfa1de1faf4336 Mon Sep 17 00:00:00 2001 From: GHOSt Date: Sat, 15 Jan 2022 11:15:56 +0000 Subject: [PATCH 1/2] strip comments --- src/compiler/compile/nodes/EachBlock.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/compile/nodes/EachBlock.ts b/src/compiler/compile/nodes/EachBlock.ts index bb78845dd927..0ef5baf1814c 100644 --- a/src/compiler/compile/nodes/EachBlock.ts +++ b/src/compiler/compile/nodes/EachBlock.ts @@ -63,7 +63,7 @@ export default class EachBlock extends AbstractBlock { ([this.const_tags, this.children] = get_const_tags(info.children, component, this, this)); if (this.has_animation) { - this.children = this.children.filter(child => !isEmptyNode(child)); + this.children = this.children.filter(child => !(child.type == 'Comment' || isEmptyNode(child))); if (this.children.length !== 1) { const child = this.children.find(child => !!(child as Element).animation); From e5809830e51a977c9e54d59012190be716d0e90a Mon Sep 17 00:00:00 2001 From: GHOSt Date: Sat, 15 Jan 2022 11:16:06 +0000 Subject: [PATCH 2/2] test for comment stripping --- .../samples/animation-each-with-comment/errors.json | 1 + .../samples/animation-each-with-comment/input.svelte | 11 +++++++++++ 2 files changed, 12 insertions(+) create mode 100644 test/validator/samples/animation-each-with-comment/errors.json create mode 100644 test/validator/samples/animation-each-with-comment/input.svelte diff --git a/test/validator/samples/animation-each-with-comment/errors.json b/test/validator/samples/animation-each-with-comment/errors.json new file mode 100644 index 000000000000..0637a088a01e --- /dev/null +++ b/test/validator/samples/animation-each-with-comment/errors.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/validator/samples/animation-each-with-comment/input.svelte b/test/validator/samples/animation-each-with-comment/input.svelte new file mode 100644 index 000000000000..5c32ef5dfbc3 --- /dev/null +++ b/test/validator/samples/animation-each-with-comment/input.svelte @@ -0,0 +1,11 @@ + + +
+ {#each [] as n (n)} + + +
+ {/each} +