diff --git a/src/compiler/compile/render_dom/wrappers/EachBlock.ts b/src/compiler/compile/render_dom/wrappers/EachBlock.ts index 42792efce7..e3a400f186 100644 --- a/src/compiler/compile/render_dom/wrappers/EachBlock.ts +++ b/src/compiler/compile/render_dom/wrappers/EachBlock.ts @@ -214,7 +214,9 @@ export default class EachBlockWrapper extends Wrapper { if (this.block.has_intro_method || this.block.has_outro_method) { block.builders.intro.add_block(deindent` - for (var #i = 0; #i < ${this.vars.data_length}; #i += 1) @transition_in(${this.vars.iterations}[#i]); + for (var #i = 0; #i < ${this.vars.data_length}; #i += 1) { + @transition_in(${this.vars.iterations}[#i]); + } `); } @@ -343,17 +345,23 @@ export default class EachBlockWrapper extends Wrapper { `); block.builders.create.add_block(deindent` - for (#i = 0; #i < ${view_length}; #i += 1) ${iterations}[#i].c(); + for (#i = 0; #i < ${view_length}; #i += 1) { + ${iterations}[#i].c(); + } `); if (parent_nodes && this.renderer.options.hydratable) { block.builders.claim.add_block(deindent` - for (#i = 0; #i < ${view_length}; #i += 1) ${iterations}[#i].l(${parent_nodes}); + for (#i = 0; #i < ${view_length}; #i += 1) { + ${iterations}[#i].l(${parent_nodes}); + } `); } block.builders.mount.add_block(deindent` - for (#i = 0; #i < ${view_length}; #i += 1) ${iterations}[#i].m(${initial_mount_node}, ${initial_anchor_node}); + for (#i = 0; #i < ${view_length}; #i += 1) { + ${iterations}[#i].m(${initial_mount_node}, ${initial_anchor_node}); + } `); const dynamic = this.block.has_update_method; @@ -378,12 +386,16 @@ export default class EachBlockWrapper extends Wrapper { if (this.block.has_outros) { block.builders.outro.add_block(deindent` - for (#i = 0; #i < ${view_length}; #i += 1) @transition_out(${iterations}[#i]); + for (#i = 0; #i < ${view_length}; #i += 1) { + @transition_out(${iterations}[#i]); + } `); } block.builders.destroy.add_block(deindent` - for (#i = 0; #i < ${view_length}; #i += 1) ${iterations}[#i].d(${parent_node ? '' : 'detaching'}); + for (#i = 0; #i < ${view_length}; #i += 1) { + ${iterations}[#i].d(${parent_node ? '' : 'detaching'}); + } `); } @@ -499,7 +511,9 @@ export default class EachBlockWrapper extends Wrapper { `); remove_old_blocks = deindent` @group_outros(); - for (#i = ${this.vars.each_block_value}.${length}; #i < ${view_length}; #i += 1) ${out}(#i); + for (#i = ${this.vars.each_block_value}.${length}; #i < ${view_length}; #i += 1) { + ${out}(#i); + } @check_outros(); `; } else { @@ -534,8 +548,10 @@ export default class EachBlockWrapper extends Wrapper { if (this.block.has_outros) { block.builders.outro.add_block(deindent` ${iterations} = ${iterations}.filter(@_Boolean); - for (let #i = 0; #i < ${view_length}; #i += 1) @transition_out(${iterations}[#i]);` - ); + for (let #i = 0; #i < ${view_length}; #i += 1) { + @transition_out(${iterations}[#i]); + } + `); } block.builders.destroy.add_block(`@destroy_each(${iterations}, detaching);`); diff --git a/test/js/samples/each-block-keyed-animated/expected.js b/test/js/samples/each-block-keyed-animated/expected.js index ee14dc8559..7cd24d8141 100644 --- a/test/js/samples/each-block-keyed-animated/expected.js +++ b/test/js/samples/each-block-keyed-animated/expected.js @@ -86,13 +86,17 @@ function create_fragment(ctx) { return { c() { - for (i = 0; i < each_blocks.length; i += 1) each_blocks[i].c(); + for (i = 0; i < each_blocks.length; i += 1) { + each_blocks[i].c(); + } each_1_anchor = empty(); }, m(target, anchor) { - for (i = 0; i < each_blocks.length; i += 1) each_blocks[i].m(target, anchor); + for (i = 0; i < each_blocks.length; i += 1) { + each_blocks[i].m(target, anchor); + } insert(target, each_1_anchor, anchor); }, @@ -108,7 +112,9 @@ function create_fragment(ctx) { o: noop, d(detaching) { - for (i = 0; i < each_blocks.length; i += 1) each_blocks[i].d(detaching); + for (i = 0; i < each_blocks.length; i += 1) { + each_blocks[i].d(detaching); + } if (detaching) { detach(each_1_anchor); diff --git a/test/js/samples/each-block-keyed/expected.js b/test/js/samples/each-block-keyed/expected.js index 8c37abde7f..6227383caf 100644 --- a/test/js/samples/each-block-keyed/expected.js +++ b/test/js/samples/each-block-keyed/expected.js @@ -70,13 +70,17 @@ function create_fragment(ctx) { return { c() { - for (i = 0; i < each_blocks.length; i += 1) each_blocks[i].c(); + for (i = 0; i < each_blocks.length; i += 1) { + each_blocks[i].c(); + } each_1_anchor = empty(); }, m(target, anchor) { - for (i = 0; i < each_blocks.length; i += 1) each_blocks[i].m(target, anchor); + for (i = 0; i < each_blocks.length; i += 1) { + each_blocks[i].m(target, anchor); + } insert(target, each_1_anchor, anchor); }, @@ -90,7 +94,9 @@ function create_fragment(ctx) { o: noop, d(detaching) { - for (i = 0; i < each_blocks.length; i += 1) each_blocks[i].d(detaching); + for (i = 0; i < each_blocks.length; i += 1) { + each_blocks[i].d(detaching); + } if (detaching) { detach(each_1_anchor);