prevent empty if block

pull/3106/head
Rich Harris 6 years ago
parent f9fbefe5eb
commit b9b8575f55

@ -444,16 +444,23 @@ export default class EachBlockWrapper extends Wrapper {
${iterations}[#i].m(${update_mount_node}, ${anchor}); ${iterations}[#i].m(${update_mount_node}, ${anchor});
} }
` `
: deindent` : has_transitions
? deindent`
if (${iterations}[#i]) { if (${iterations}[#i]) {
${has_transitions && `@transition_in(${this.vars.iterations}[#i], 1);`} @transition_in(${this.vars.iterations}[#i], 1);
} else { } else {
${iterations}[#i] = ${create_each_block}(child_ctx); ${iterations}[#i] = ${create_each_block}(child_ctx);
${iterations}[#i].c(); ${iterations}[#i].c();
${has_transitions && `@transition_in(${this.vars.iterations}[#i], 1);`} @transition_in(${this.vars.iterations}[#i], 1);
${iterations}[#i].m(${update_mount_node}, ${anchor});
}
`
: deindent`
if (!${iterations}[#i]) {
${iterations}[#i] = ${create_each_block}(child_ctx);
${iterations}[#i].c();
${iterations}[#i].m(${update_mount_node}, ${anchor}); ${iterations}[#i].m(${update_mount_node}, ${anchor});
} }
`; `;
const start = this.block.has_update_method ? '0' : `old_length`; const start = this.block.has_update_method ? '0' : `old_length`;

Loading…
Cancel
Save