Fixes an error with outros and elseifs

This is a fix for when an elseif doesn't have a final else, and the following error was thrown:

```
TypeError: Cannot read property 'o' of undefined
```

See https://svelte.technology/repl?version=2.12.0&gist=c33d308077447f8ba06b79d8ef5ab1e4
pull/1688/head
Jacob Wright 6 years ago
parent 4890d4dc02
commit 96c4455af9

@ -139,9 +139,10 @@ export default class IfBlock extends Node {
this.buildCompoundWithOutros(block, parentNode, parentNodes, branches, dynamic, vars); this.buildCompoundWithOutros(block, parentNode, parentNodes, branches, dynamic, vars);
if (this.compiler.options.nestedTransitions) { if (this.compiler.options.nestedTransitions) {
block.builders.outro.addLine( block.builders.outro.addBlock(deindent`
`${name}.o(#outrocallback);` if (${name}) ${name}.o(#outrocallback);
); else #outrocallback();
`);
} }
} else { } else {
this.buildCompound(block, parentNode, parentNodes, branches, dynamic, vars); this.buildCompound(block, parentNode, parentNodes, branches, dynamic, vars);

@ -0,0 +1,8 @@
export default {
nestedTransitions: true,
test ( assert, component, target ) {
// Would cause "TypeError: Cannot read property 'o' of undefined"
component.set({ foo: false });
}
};

@ -0,0 +1,16 @@
{#if foo}
{#if false}
<Component/>
{:elseif false}
<Component/>
{/if}
{/if}
<script>
export default {
components: {
Component: './Component.html',
},
data: () => ({ foo: true }),
}
</script>
Loading…
Cancel
Save