diff --git a/src/generators/dom/visitors/IfBlock.ts b/src/generators/dom/visitors/IfBlock.ts index f0a54a4524..117f979252 100644 --- a/src/generators/dom/visitors/IfBlock.ts +++ b/src/generators/dom/visitors/IfBlock.ts @@ -173,8 +173,10 @@ function simple( ` : branch.hasIntroMethod ? deindent` - if ( !${name} ) ${name} = ${branch.block}( ${params}, ${block.component} ); - ${name}.create(); + if ( !${name} ) { + ${name} = ${branch.block}( ${params}, ${block.component} ); + ${name}.create(); + } ${name}.intro( ${parentNode}, ${anchor} ); ` : deindent` diff --git a/test/runtime/samples/transition-js-if-block-in-each-block-bidi/_config.js b/test/runtime/samples/transition-js-if-block-in-each-block-bidi/_config.js new file mode 100644 index 0000000000..f7ce778056 --- /dev/null +++ b/test/runtime/samples/transition-js-if-block-in-each-block-bidi/_config.js @@ -0,0 +1,45 @@ +export default { + data: { + threshold: 5 + }, + + html: ` +
1
+
2
+
3
+
4
+
5
+ `, + + test ( assert, component, target, window, raf ) { + const divs = target.querySelectorAll('div'); + + assert.equal(divs[0].foo, 0); + + raf.tick(100); + assert.equal(divs[0].foo, 1); + + component.set({ threshold: 4 }); + assert.equal( divs[4].foo, 1 ); + + raf.tick( 200 ); + assert.htmlEqual(target.innerHTML, ` +
1
+
2
+
3
+
4
+ `); + + component.set({ threshold: 3 }); + assert.equal( divs[3].foo, 1 ); + + raf.tick( 300 ); + assert.htmlEqual(target.innerHTML, ` +
1
+
2
+
3
+ `); + + component.destroy(); + } +}; \ No newline at end of file diff --git a/test/runtime/samples/transition-js-if-block-in-each-block-bidi/main.html b/test/runtime/samples/transition-js-if-block-in-each-block-bidi/main.html new file mode 100644 index 0000000000..754c4a5bfd --- /dev/null +++ b/test/runtime/samples/transition-js-if-block-in-each-block-bidi/main.html @@ -0,0 +1,20 @@ +{{#each [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] as number}} + {{#if threshold >= number}} +
{{number}}
+ {{/if}} +{{/each}} + + \ No newline at end of file