Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix destruction of compound if blocks with outros #572

Merged
merged 1 commit into from
May 6, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions src/generators/dom/visitors/IfBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,9 @@ export default function visitIfBlock ( generator, block, state, node ) {
} else if ( node.next ) {
node.next.usedAsAnchor = true;
}

block.builders.destroy.addLine(
`${if_name}${name}.destroy( ${state.parentNode ? 'false' : 'detach'} );`
);
}

function simple ( generator, block, state, node, branch, dynamic, { name, anchor, params } ) {
function simple ( generator, block, state, node, branch, dynamic, { name, anchor, params, if_name } ) {
block.builders.create.addBlock( deindent`
var ${name} = (${branch.condition}) && ${branch.block}( ${params}, ${block.component} );
` );
Expand Down Expand Up @@ -151,6 +147,10 @@ function simple ( generator, block, state, node, branch, dynamic, { name, anchor
${exit}
}
` );

block.builders.destroy.addLine(
`${if_name}${name}.destroy( ${state.parentNode ? 'false' : 'detach'} );`
);
}

function compound ( generator, block, state, node, branches, dynamic, { name, anchor, params, hasElse, if_name } ) {
Expand Down Expand Up @@ -201,6 +201,10 @@ function compound ( generator, block, state, node, branches, dynamic, { name, an
}
` );
}

block.builders.destroy.addLine(
`${if_name}${name}.destroy( ${state.parentNode ? 'false' : 'detach'} );`
);
}

// if any of the siblings have outros, we need to keep references to the blocks
Expand Down Expand Up @@ -304,4 +308,8 @@ function compoundWithOutros ( generator, block, state, node, branches, dynamic,
}
` );
}

block.builders.destroy.addLine(
`${if_current_block_index}${if_blocks}[ ${current_block_index} ].destroy( ${state.parentNode ? 'false' : 'detach'} );`
);
}