@@ -47,8 +47,7 @@ export default function visitIfBlock ( generator, block, state, node ) {
47
47
const params = block . params . join ( ', ' ) ;
48
48
const name = generator . getUniqueName ( `if_block` ) ;
49
49
const getBlock = block . getUniqueName ( `get_block` ) ;
50
- const currentBlock = block . getUniqueName ( `current_block` ) ;
51
- const _currentBlock = block . getUniqueName ( `_current_block` ) ;
50
+ const current_block = block . getUniqueName ( `current_block` ) ;
52
51
53
52
const branches = getBranches ( generator , block , state , node , generator . getUniqueName ( `create_if_block` ) ) ;
54
53
const dynamic = branches . some ( branch => branch . dynamic ) ;
@@ -63,8 +62,8 @@ export default function visitIfBlock ( generator, block, state, node ) {
63
62
} ) . join ( '\n' ) }
64
63
}
65
64
66
- var ${ currentBlock } = ${ getBlock } ( ${ params } );
67
- var ${ name } = ${ currentBlock } && ${ currentBlock } ( ${ params } , ${ block . component } );
65
+ var ${ current_block } = ${ getBlock } ( ${ params } );
66
+ var ${ name } = ${ current_block } && ${ current_block } ( ${ params } , ${ block . component } );
68
67
` ) ;
69
68
70
69
const isToplevel = ! state . parentNode ;
@@ -75,26 +74,21 @@ export default function visitIfBlock ( generator, block, state, node ) {
75
74
block . builders . create . addLine ( `if ( ${ name } ) ${ name } .mount( ${ state . parentNode } , ${ anchor } );` ) ;
76
75
}
77
76
78
- block . builders . update . addBlock ( deindent `
79
- var ${ _currentBlock } = ${ currentBlock } ;
80
- ${ currentBlock } = ${ getBlock } ( ${ params } );
81
- ` ) ;
82
-
83
77
if ( dynamic ) {
84
78
block . builders . update . addBlock ( deindent `
85
- if ( ${ _currentBlock } === ${ currentBlock } && ${ name } ) {
79
+ if ( ${ current_block } === ( ${ current_block } = ${ getBlock } ( ${ params } ) ) && ${ name } ) {
86
80
${ name } .update( changed, ${ params } );
87
81
} else {
88
82
if ( ${ name } ) ${ name } .destroy( true );
89
- ${ name } = ${ currentBlock } && ${ currentBlock } ( ${ params } , ${ block . component } );
83
+ ${ name } = ${ current_block } && ${ current_block } ( ${ params } , ${ block . component } );
90
84
if ( ${ name } ) ${ name } .mount( ${ anchor } .parentNode, ${ anchor } );
91
85
}
92
86
` ) ;
93
87
} else {
94
88
block . builders . update . addBlock ( deindent `
95
- if ( ${ _currentBlock } !== ${ currentBlock } ) {
89
+ if ( ${ current_block } !== ( ${ current_block } = ${ getBlock } ( ${ params } ) ) ) {
96
90
if ( ${ name } ) ${ name } .destroy( true );
97
- ${ name } = ${ currentBlock } && ${ currentBlock } ( ${ params } , ${ block . component } );
91
+ ${ name } = ${ current_block } && ${ current_block } ( ${ params } , ${ block . component } );
98
92
if ( ${ name } ) ${ name } .mount( ${ anchor } .parentNode, ${ anchor } );
99
93
}
100
94
` ) ;
0 commit comments