From dd2e5e8b2b80346c9ad5e7aa1d0e42cc888cc1d4 Mon Sep 17 00:00:00 2001 From: Rich-Harris Date: Thu, 4 May 2017 09:34:07 -0400 Subject: [PATCH] mount yield blocks immediately, if yield has a parent node (fixes #561) --- src/generators/dom/visitors/YieldTag.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/generators/dom/visitors/YieldTag.js b/src/generators/dom/visitors/YieldTag.js index aa95cd284e07..81dcb3ad5314 100644 --- a/src/generators/dom/visitors/YieldTag.js +++ b/src/generators/dom/visitors/YieldTag.js @@ -1,9 +1,11 @@ export default function visitYieldTag ( generator, block, state ) { - block.builders.mount.addLine( - `${block.component}._yield && ${block.component}._yield.mount( ${state.parentNode || block.target}, null );` + const parentNode = state.parentNode || block.target; + + ( state.parentNode ? block.builders.create : block.builders.mount ).addLine( + `if ( ${block.component}._yield ) ${block.component}._yield.mount( ${parentNode}, null );` ); block.builders.destroy.addLine( - `${block.component}._yield && ${block.component}._yield.destroy( detach );` + `if ( ${block.component}._yield ) ${block.component}._yield.destroy( detach );` ); } \ No newline at end of file