Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions modules/@angular/core/src/linker/view_container_ref.ts
Expand Up @@ -187,7 +187,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 */
Expand All @@ -214,7 +215,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);
}
Expand Down