From f97601ff1d40c9b01d6954e2ac365aa6ff541ca5 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Wed, 16 May 2018 21:55:14 -0400 Subject: [PATCH] always create outro method for top-level block - fixes #1470 --- src/compile/dom/index.ts | 4 ++++ .../if-block-component-without-outro/Widget.html | 1 + .../if-block-component-without-outro/_config.js | 15 +++++++++++++++ .../if-block-component-without-outro/main.html | 11 +++++++++++ 4 files changed, 31 insertions(+) create mode 100644 test/runtime/samples/if-block-component-without-outro/Widget.html create mode 100644 test/runtime/samples/if-block-component-without-outro/_config.js create mode 100644 test/runtime/samples/if-block-component-without-outro/main.html diff --git a/src/compile/dom/index.ts b/src/compile/dom/index.ts index dc47f76392..543562e589 100644 --- a/src/compile/dom/index.ts +++ b/src/compile/dom/index.ts @@ -55,6 +55,10 @@ export default function dom( compiler.fragment.build(); const { block } = compiler.fragment; + if (compiler.options.nestedTransitions) { + block.hasOutroMethod = true; + } + // prevent fragment being created twice (#1063) if (options.customElement) block.builders.create.addLine(`this.c = @noop;`); diff --git a/test/runtime/samples/if-block-component-without-outro/Widget.html b/test/runtime/samples/if-block-component-without-outro/Widget.html new file mode 100644 index 0000000000..c66687863a --- /dev/null +++ b/test/runtime/samples/if-block-component-without-outro/Widget.html @@ -0,0 +1 @@ +
A wild component appears
\ No newline at end of file diff --git a/test/runtime/samples/if-block-component-without-outro/_config.js b/test/runtime/samples/if-block-component-without-outro/_config.js new file mode 100644 index 0000000000..c071648432 --- /dev/null +++ b/test/runtime/samples/if-block-component-without-outro/_config.js @@ -0,0 +1,15 @@ +export default { + skipIntroByDefault: true, + nestedTransitions: true, + + data: { + foo: true, + }, + + html: '
A wild component appears
', + + test(assert, component, target) { + component.set({ foo: false }); + assert.htmlEqual(target.innerHTML, ''); + }, +}; diff --git a/test/runtime/samples/if-block-component-without-outro/main.html b/test/runtime/samples/if-block-component-without-outro/main.html new file mode 100644 index 0000000000..f043b3644a --- /dev/null +++ b/test/runtime/samples/if-block-component-without-outro/main.html @@ -0,0 +1,11 @@ +{#if foo} + +{/if} + + \ No newline at end of file