add component.destroy() as alias of component.teardown(), to align with ondestroy

pull/316/head
Rich Harris 8 years ago
parent 543ee2f870
commit 1736498bde

@ -355,12 +355,13 @@ export default function dom ( parsed, source, options, names ) {
${name}.prototype._flush = ${shared._flush}; ${name}.prototype._flush = ${shared._flush};
` ); ` );
// TODO deprecate component.teardown()
builders.main.addBlock( deindent` builders.main.addBlock( deindent`
${name}.prototype._set = function _set ( newState ) { ${name}.prototype._set = function _set ( newState ) {
${builders._set} ${builders._set}
}; };
${name}.prototype.teardown = function teardown ( detach ) { ${name}.prototype.teardown = ${name}.prototype.destroy = function destroy ( detach ) {
this.fire( 'teardown' );${templateProperties.ondestroy ? `\ntemplate.ondestroy.call( this );` : ``} this.fire( 'teardown' );${templateProperties.ondestroy ? `\ntemplate.ondestroy.call( this );` : ``}
this._fragment.teardown( detach !== false ); this._fragment.teardown( detach !== false );

@ -137,7 +137,7 @@ export default {
` ); ` );
} }
generator.current.builders.teardown.addLine( `${name}.teardown( ${isToplevel ? 'detach' : 'false'} );` ); generator.current.builders.teardown.addLine( `${name}.destroy( ${isToplevel ? 'detach' : 'false'} );` );
generator.current.builders.init.addBlock( local.init ); generator.current.builders.init.addBlock( local.init );
if ( !local.update.isEmpty() ) generator.current.builders.update.addBlock( local.update ); if ( !local.update.isEmpty() ) generator.current.builders.update.addBlock( local.update );

Loading…
Cancel
Save