fix(upgrade): ensure downgraded components are destroyed in the Angular zone

This commit is contained in:
George Kalpakas
2017-09-25 12:39:51 +03:00
committed by Alex Rickabaugh
parent 745b59f49c
commit 4e6aa9c2db
3 changed files with 42 additions and 4 deletions

View File

@ -203,11 +203,13 @@ export class DowngradeComponentAdapter {
}
registerCleanup(needsNgZone: boolean) {
const destroyComponentRef = this.wrapCallback(() => this.componentRef.destroy());
this.element.on !('$destroy', () => {
this.componentScope.$destroy();
this.componentRef.injector.get(TestabilityRegistry)
.unregisterApplication(this.componentRef.location.nativeElement);
this.componentRef.destroy();
destroyComponentRef();
if (needsNgZone) {
this.appRef.detachView(this.componentRef.hostView);
}