Closed
Description
Very minor thing I noticed while working on #525 — if you have an if
block (or a chain of if, elseif, elseif...) followed by an else
block, then there's no need to check for the existence of current_block
:
function get_block ( state ) {
if ( state.foo ) return create_if_block;
return create_if_block_1;
}
var current_block = get_block( state );
-var if_block = current_block && current_block( state, component );
+var if_block = current_block( state, component );
return {
mount: function ( target, anchor ) {
// ...
},
update: function ( changed, state ) {
// ...
if ( current_block !== ( current_block = get_block( state ) ) ) {
- if ( if_block ) if_block.destroy( true );
- if_block = current_block && current_block( state, component );
- if ( if_block ) if_block.mount( if_block_anchor.parentNode, if_block_anchor );
+ if_block.destroy( true );
+ if_block = current_block( state, component );
+ if_block.mount( if_block_anchor.parentNode, if_block_anchor );
}
},
destroy: function ( detach ) {
// ...
- if ( if_block ) if_block.destroy( detach );
+ if_block.destroy( detach );
}
};
This'll have to wait until after #525 in order to avoid merge conflicts.
Metadata
Metadata
Assignees
Labels
No labels