fix(core): ViewContainerRef.indexOf doesn't throw error when empty (#13220)
PR Close #13220
This commit is contained in:
parent
9e5617e41e
commit
a277e97dd7
|
@ -186,7 +186,8 @@ export class ViewContainerRef_ implements ViewContainerRef {
|
||||||
}
|
}
|
||||||
|
|
||||||
indexOf(viewRef: ViewRef): number {
|
indexOf(viewRef: ViewRef): number {
|
||||||
return this._element.nestedViews.indexOf((<ViewRef_<any>>viewRef).internalView);
|
return this.length ? this._element.nestedViews.indexOf((<ViewRef_<any>>viewRef).internalView) :
|
||||||
|
-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @internal */
|
/** @internal */
|
||||||
|
@ -213,7 +214,7 @@ export class ViewContainerRef_ implements ViewContainerRef {
|
||||||
return wtfLeave(s, view.ref);
|
return wtfLeave(s, view.ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
clear() {
|
clear(): void {
|
||||||
for (let i = this.length - 1; i >= 0; i--) {
|
for (let i = this.length - 1; i >= 0; i--) {
|
||||||
this.remove(i);
|
this.remove(i);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue