Skip to content

Commit

Permalink
each animate allow having comment siblings
Browse files Browse the repository at this point in the history
  • Loading branch information
tanhauhau committed Apr 8, 2022
1 parent f6fd8e1 commit a8417f1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/compiler/compile/nodes/EachBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 => !isEmptyNode(child) && !isCommentNode(child));

if (this.children.length !== 1) {
const child = this.children.find(child => !!(child as Element).animation);
Expand All @@ -83,3 +83,6 @@ export default class EachBlock extends AbstractBlock {
function isEmptyNode(node: INode) {
return node.type === 'Text' && node.data.trim() === '';
}
function isCommentNode(node: INode) {
return node.type === 'Comment';
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<script>
export let things;
function foo() {}
</script>

{#each things as thing (thing)}
<!-- some comment -->
<div animate:foo></div>
{/each}

0 comments on commit a8417f1

Please sign in to comment.