Skip to content

Commit

Permalink
fix(cdk): add checks before destroying hostView and viewRef (#6083)
Browse files Browse the repository at this point in the history
  • Loading branch information
IKatsuba authored Nov 24, 2023
1 parent 26995cd commit 8ef84b5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions projects/cdk/abstract/portal-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,18 @@ export abstract class AbstractTuiPortalService {
}

remove<C>({hostView}: ComponentRef<C>): void {
hostView.destroy();
if (!hostView.destroyed) {
hostView.destroy();
}
}

addTemplate<C>(templateRef: TemplateRef<C>, context?: C): EmbeddedViewRef<C> {
return this.safeHost.addTemplateChild(templateRef, context);
}

removeTemplate<C>(viewRef: EmbeddedViewRef<C>): void {
viewRef.destroy();
if (!viewRef.destroyed) {
viewRef.destroy();
}
}
}

0 comments on commit 8ef84b5

Please sign in to comment.