each animate allow having comment siblings (#7435)

Co-authored-by: GHOST <ghostdevbusiness@gmail.com>

Co-authored-by: GHOST <ghostdevbusiness@gmail.com>
pull/6583/head
Tan Li Hau 3 years ago committed by GitHub
parent fc19537995
commit d9687da632
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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);
@ -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';
}

@ -0,0 +1,9 @@
<script>
export let things;
function foo() {}
</script>
{#each things as thing (thing)}
<!-- some comment -->
<div animate:foo></div>
{/each}
Loading…
Cancel
Save