Skip to content

Commit 4622d0b

Browse files
crisbetojasonaden
authored andcommitted
fix(ivy): detach ViewRef from ApplicationRef on destroy (angular#27276)
Currently we store the `_appRef` when a `ViewRef` is attached, however we don't use it for anything. These changes use it to detach the view from the `ApplicationRef` when it is destroyed. These changes also fix that the `ComponentRef` doesn't remove its `ViewRef` on destroy. PR Close angular#27276
1 parent 0487fbe commit 4622d0b

File tree

2 files changed

+286
-252
lines changed

2 files changed

+286
-252
lines changed

packages/core/src/render3/view_ref.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ export class ViewRef<T> implements viewEngine_EmbeddedViewRef<T>, viewEngine_Int
5959
}
6060

6161
destroy(): void {
62-
if (this._viewContainerRef && viewAttached(this._view)) {
62+
if (this._appRef) {
63+
this._appRef.detachView(this);
64+
} else if (this._viewContainerRef && viewAttached(this._view)) {
6365
this._viewContainerRef.detach(this._viewContainerRef.indexOf(this));
6466
this._viewContainerRef = null;
6567
}

0 commit comments

Comments
 (0)