pull/603/head
Rich Harris 8 years ago
parent 5c055a9f0c
commit 8a57ae8b54

@ -200,9 +200,8 @@ export default class Block {
this.builders.create.addLine( `${this.autofocus}.focus();` );
}
// minor hack we need to ensure that any {{{triples}}} are detached
// first, so we append normal detach statements to detachRaw
this.builders.detachRaw.addBlock( this.builders.unmount ); // TODO reverse this, using addBlockAtStart?
// minor hack we need to ensure that any {{{triples}}} are detached first
this.builders.unmount.addBlockAtStart( this.builders.detachRaw );
const properties = new CodeBuilder();
@ -282,12 +281,12 @@ export default class Block {
}
}
if ( this.builders.detachRaw.isEmpty() ) {
if ( this.builders.unmount.isEmpty() ) {
properties.addBlock( `unmount: ${this.generator.helper('noop')},`);
} else {
properties.addBlock( deindent`
unmount: function () {
${this.builders.detachRaw}
${this.builders.unmount}
},
` );
}
@ -296,8 +295,7 @@ export default class Block {
properties.addBlock( `destroy: ${this.generator.helper( 'noop' )}` );
} else {
properties.addBlock( deindent`
destroy: function ( detach ) {
${!this.builders.detachRaw.isEmpty() && `if ( detach ) this.unmount();`}
destroy: function () {
${this.builders.destroy}
}
` );

@ -122,7 +122,7 @@ export default function visitComponent ( generator: DomGenerator, block: Block,
}
block.builders.destroy.addLine(
`${yieldFragment}.destroy( false );`
`${yieldFragment}.destroy();`
);
componentInitProperties.push( `_yield: ${yieldFragment}`);

@ -159,7 +159,7 @@ function simple ( generator: DomGenerator, block: Block, state: State, node: Nod
);
block.builders.destroy.addLine(
`${if_name}${name}.destroy( false );`
`${if_name}${name}.destroy();`
);
}
@ -277,7 +277,8 @@ function compoundWithOutros ( generator: DomGenerator, block: Block, state: Stat
const destroyOldBlock = deindent`
${name}.outro( function () {
${if_blocks}[ ${previous_block_index} ].destroy( true );
${if_blocks}[ ${previous_block_index} ].unmount();
${if_blocks}[ ${previous_block_index} ].destroy();
${if_blocks}[ ${previous_block_index} ] = null;
});
`;
@ -325,7 +326,10 @@ function compoundWithOutros ( generator: DomGenerator, block: Block, state: Stat
` );
}
block.builders.destroy.addLine(
`${if_current_block_index}${if_blocks}[ ${current_block_index} ].destroy( ${state.parentNode ? 'false' : 'detach'} );`
);
block.builders.destroy.addLine( deindent`
${if_current_block_index}{
${if_blocks}[ ${current_block_index} ].unmount();
${if_blocks}[ ${current_block_index} ].destroy();
}
` );
}

@ -16,6 +16,7 @@ export function detachBetween ( before, after ) {
}
}
// TODO this is out of date
export function destroyEach ( iterations, detach, start ) {
for ( var i = start; i < iterations.length; i += 1 ) {
if ( iterations[i] ) iterations[i].destroy( detach );

Loading…
Cancel
Save