fix compound ifs with outros and no dependencies (#3595)

pull/3749/head
Conduitry 6 years ago
parent 8d7d0ff7dd
commit 8e5b5cbb5d

@ -271,8 +271,8 @@ export default class IfBlockWrapper extends Wrapper {
? b` ? b`
${snippet && ( ${snippet && (
dependencies.length > 0 dependencies.length > 0
? b`if ((${condition} == null) || ${changed(dependencies)}) ${condition} = !!(${snippet})` ? b`if (${condition} == null || ${changed(dependencies)}) ${condition} = !!${snippet}`
: b`if (${condition} == null) ${condition} = !!(${snippet})` : b`if (${condition} == null) ${condition} = !!${snippet}`
)} )}
if (${condition}) return ${block.name};` if (${condition}) return ${block.name};`
: b`return ${block.name};`)} : b`return ${block.name};`)}
@ -388,7 +388,11 @@ export default class IfBlockWrapper extends Wrapper {
function ${select_block_type}(#changed, #ctx) { function ${select_block_type}(#changed, #ctx) {
${this.branches.map(({ dependencies, condition, snippet }, i) => condition ${this.branches.map(({ dependencies, condition, snippet }, i) => condition
? b` ? b`
${snippet && b`if ((${condition} == null) || ${changed(dependencies)}) ${condition} = !!(${snippet})`} ${snippet && (
dependencies.length > 0
? b`if (${condition} == null || ${changed(dependencies)}) ${condition} = !!${snippet}`
: b`if (${condition} == null) ${condition} = !!${snippet}`
)}
if (${condition}) return ${i};` if (${condition}) return ${i};`
: b`return ${i};`)} : b`return ${i};`)}
${!has_else && b`return -1;`} ${!has_else && b`return -1;`}

Loading…
Cancel
Save