fix(ivy): throw a descriptive error when trying to insert / move destroyed view (#27289)
PR Close #27289
This commit is contained in:

committed by
Jason Aden

parent
d0e8020506
commit
0487fbe236
@ -265,6 +265,7 @@ export class ComponentRef<T> extends viewEngine_ComponentRef<T> {
|
||||
ngDevMode && assertDefined(this.destroyCbs, 'NgModule already destroyed');
|
||||
this.destroyCbs !.forEach(fn => fn());
|
||||
this.destroyCbs = null;
|
||||
this.hostView.destroy();
|
||||
}
|
||||
onDestroy(callback: () => void): void {
|
||||
ngDevMode && assertDefined(this.destroyCbs, 'NgModule already destroyed');
|
||||
|
@ -265,6 +265,9 @@ export function createContainerRef(
|
||||
}
|
||||
|
||||
move(viewRef: viewEngine_ViewRef, newIndex: number): viewEngine_ViewRef {
|
||||
if (viewRef.destroyed) {
|
||||
throw new Error('Cannot move a destroyed View in a ViewContainer!');
|
||||
}
|
||||
const index = this.indexOf(viewRef);
|
||||
this.detach(index);
|
||||
this.insert(viewRef, this._adjustIndex(newIndex));
|
||||
|
Reference in New Issue
Block a user