From 67d4d60c3ab1ecce0467a06b8075f508dd8c01eb Mon Sep 17 00:00:00 2001 From: Jacob Wright Date: Wed, 29 Aug 2018 09:52:43 -0600 Subject: [PATCH] Fixes keyed each blocks for outro Fixes #1706 --- src/compile/nodes/EachBlock.ts | 2 +- .../transition-js-nested-each-keyed-2/Widget.html | 3 +++ .../transition-js-nested-each-keyed-2/_config.js | 13 +++++++++++++ .../transition-js-nested-each-keyed-2/main.html | 9 +++++++++ 4 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 test/runtime/samples/transition-js-nested-each-keyed-2/Widget.html create mode 100644 test/runtime/samples/transition-js-nested-each-keyed-2/_config.js create mode 100644 test/runtime/samples/transition-js-nested-each-keyed-2/main.html diff --git a/src/compile/nodes/EachBlock.ts b/src/compile/nodes/EachBlock.ts index bb726982df..2a62249c63 100644 --- a/src/compile/nodes/EachBlock.ts +++ b/src/compile/nodes/EachBlock.ts @@ -331,7 +331,7 @@ export default class EachBlock extends Node { ${this.block.hasAnimation && `for (let #i = 0; #i < ${blocks}.length; #i += 1) ${blocks}[#i].a();`} `); - if (this.compiler.options.nestedTransitions) { + if (this.block.hasOutros && this.compiler.options.nestedTransitions) { const countdown = block.getUniqueName('countdown'); block.builders.outro.addBlock(deindent` const ${countdown} = @callAfter(#outrocallback, ${blocks}.length); diff --git a/test/runtime/samples/transition-js-nested-each-keyed-2/Widget.html b/test/runtime/samples/transition-js-nested-each-keyed-2/Widget.html new file mode 100644 index 0000000000..9b57a5905c --- /dev/null +++ b/test/runtime/samples/transition-js-nested-each-keyed-2/Widget.html @@ -0,0 +1,3 @@ +{#each things as thing (thing)} +
+{/each} diff --git a/test/runtime/samples/transition-js-nested-each-keyed-2/_config.js b/test/runtime/samples/transition-js-nested-each-keyed-2/_config.js new file mode 100644 index 0000000000..fda0786b3f --- /dev/null +++ b/test/runtime/samples/transition-js-nested-each-keyed-2/_config.js @@ -0,0 +1,13 @@ +export default { + nestedTransitions: true, + + data: { + x: true, + things: ['a', 'b'] + }, + + test(assert, component, target, window, raf) { + component.set({ x: false }); + assert.htmlEqual(target.innerHTML, ''); + }, +}; diff --git a/test/runtime/samples/transition-js-nested-each-keyed-2/main.html b/test/runtime/samples/transition-js-nested-each-keyed-2/main.html new file mode 100644 index 0000000000..d931f220a4 --- /dev/null +++ b/test/runtime/samples/transition-js-nested-each-keyed-2/main.html @@ -0,0 +1,9 @@ +{#if x} + +{/if} + + \ No newline at end of file