Skip to content

Commit

Permalink
fix(core): ViewContainerRef.indexOf doesn't throw error when empty (#…
Browse files Browse the repository at this point in the history
…13220)

PR Close #13220
  • Loading branch information
Dzmitry Shylovich authored and mhevery committed Jan 29, 2017
1 parent 9e5617e commit a277e97
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions modules/@angular/core/src/linker/view_container_ref.ts
Expand Up @@ -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 */
Expand All @@ -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);
}
Expand Down

1 comment on commit a277e97

@IgorMinar
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

caretaker note: please change the commit message in the changelog to fix(core): ViewContainerRef.indexOf should not throw error when empty

Please sign in to comment.