Skip to content

Commit 1ef9575

Browse files
committed
fix
1 parent f6eba05 commit 1ef9575

File tree

1 file changed

+2
-28
lines changed
  • src/compiler/compile/render_dom/wrappers

1 file changed

+2
-28
lines changed

src/compiler/compile/render_dom/wrappers/IfBlock.ts

+2-28
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ export default class IfBlockWrapper extends Wrapper {
264264
block.builders.init.add_block(deindent`
265265
function ${select_block_type}(changed, ctx) {
266266
${this.branches.map(({ condition, snippet, block }) => condition
267-
? `if (${snippet}) return ${block.name};`
267+
? `if (${snippet || condition}) return ${block.name};`
268268
: `return ${block.name};`)}
269269
}
270270
`);
@@ -340,32 +340,6 @@ export default class IfBlockWrapper extends Wrapper {
340340
block.add_variable(current_block_type_index);
341341
block.add_variable(name);
342342

343-
/* eslint-disable @typescript-eslint/indent,indent */
344-
if (this.needs_update) {
345-
block.builders.init.add_block(deindent`
346-
function ${select_block_type}(changed, ctx) {
347-
${this.branches.map(({ dependencies, condition, snippet, block }) => condition
348-
? deindent`
349-
${snippet && (
350-
dependencies.length > 0
351-
? `if ((${condition} == null) || ${dependencies.map(n => `changed.${n}`).join(' || ')}) ${condition} = !!(${snippet})`
352-
: `if (${condition} == null) ${condition} = !!(${snippet})`
353-
)}
354-
if (${condition}) return ${block.name};`
355-
: `return ${block.name};`)}
356-
}
357-
`);
358-
} else {
359-
block.builders.init.add_block(deindent`
360-
function ${select_block_type}(changed, ctx) {
361-
${this.branches.map(({ condition, snippet, block }) => condition
362-
? `if (${snippet}) return ${block.name};`
363-
: `return ${block.name};`)}
364-
}
365-
`);
366-
}
367-
/* eslint-enable @typescript-eslint/indent,indent */
368-
369343
/* eslint-disable @typescript-eslint/indent,indent */
370344
block.builders.init.add_block(deindent`
371345
var ${if_block_creators} = [
@@ -388,7 +362,7 @@ export default class IfBlockWrapper extends Wrapper {
388362
: deindent`
389363
function ${select_block_type}(changed, ctx) {
390364
${this.branches.map(({ condition, snippet }, i) => condition
391-
? `if (${snippet}) return ${String(i)};`
365+
? `if (${snippet || condition}) return ${String(i)};`
392366
: `return ${i};`)}
393367
${!has_else && `return -1;`}
394368
}

0 commit comments

Comments
 (0)