Merge pull request from sveltejs/outro-elseif-error

Fixes an error with outros and elseifs
pull/1690/head
Rich Harris 7 years ago committed by GitHub
commit d6fe9b4b84
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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