fix(core): ViewContainerRef.indexOf doesn't throw error when empty (#13220)

PR Close #13220
This commit is contained in:
Dzmitry Shylovich 2016-12-03 23:32:47 +03:00 committed by Miško Hevery
parent 9e5617e41e
commit a277e97dd7
1 changed files with 3 additions and 2 deletions

View File

@ -186,7 +186,8 @@ export class ViewContainerRef_ implements ViewContainerRef {
}
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 */
@ -213,7 +214,7 @@ export class ViewContainerRef_ implements ViewContainerRef {
return wtfLeave(s, view.ref);
}
clear() {
clear(): void {
for (let i = this.length - 1; i >= 0; i--) {
this.remove(i);
}