add dev mode warning for double destroy

pull/735/head
Rich Harris 8 years ago
parent 962f04f4bf
commit e2d63d1b34

@ -264,7 +264,7 @@ export default function dom(
};
${name}.prototype.teardown = ${name}.prototype.destroy = function destroy ( detach ) {
if ( this._destroyed ) return;
if ( this._destroyed ) return${options.dev && ` console.warn( 'Component was already destroyed' )`};
this.fire( 'destroy' );
${templateProperties.ondestroy && `@template.ondestroy.call( this );`}

@ -0,0 +1,21 @@
export default {
dev: true,
test(assert, component) {
const warn = console.warn; // eslint-disable-line no-console
const warnings = [];
console.warn = warning => { // eslint-disable-line no-console
warnings.push(warning);
};
component.destroy();
component.destroy();
assert.deepEqual(warnings, [
`Component was already destroyed`
]);
console.warn = warn; // eslint-disable-line no-console
}
};
Loading…
Cancel
Save