Skip to content

Commit

Permalink
fix compound ifs with outros and no dependencies (sveltejs#3595)
Browse files Browse the repository at this point in the history
  • Loading branch information
Conduitry committed Oct 19, 2019
1 parent 8d7d0ff commit 8e5b5cb
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/compiler/compile/render_dom/wrappers/IfBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,8 @@ export default class IfBlockWrapper extends Wrapper {
? b`
${snippet && (
dependencies.length > 0
? b`if ((${condition} == null) || ${changed(dependencies)}) ${condition} = !!(${snippet})`
: b`if (${condition} == null) ${condition} = !!(${snippet})`
? b`if (${condition} == null || ${changed(dependencies)}) ${condition} = !!${snippet}`
: b`if (${condition} == null) ${condition} = !!${snippet}`
)}
if (${condition}) return ${block.name};`
: b`return ${block.name};`)}
Expand Down Expand Up @@ -388,7 +388,11 @@ export default class IfBlockWrapper extends Wrapper {
function ${select_block_type}(#changed, #ctx) {
${this.branches.map(({ dependencies, condition, snippet }, i) => condition
? 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};`
: b`return ${i};`)}
${!has_else && b`return -1;`}
Expand Down

0 comments on commit 8e5b5cb

Please sign in to comment.