Skip to content

Commit

Permalink
always create outro method for top-level block - fixes #1470
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich-Harris committed May 17, 2018
1 parent cffbd27 commit f97601f
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/compile/dom/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;`);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<div>A wild component appears</div>
15 changes: 15 additions & 0 deletions test/runtime/samples/if-block-component-without-outro/_config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export default {
skipIntroByDefault: true,
nestedTransitions: true,

data: {
foo: true,
},

html: '<div>A wild component appears</div>',

test(assert, component, target) {
component.set({ foo: false });
assert.htmlEqual(target.innerHTML, '');
},
};
11 changes: 11 additions & 0 deletions test/runtime/samples/if-block-component-without-outro/main.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{#if foo}
<Widget/>
{/if}

<script>
export default {
components: {
Widget: './Widget.html'
}
};
</script>

0 comments on commit f97601f

Please sign in to comment.