X Tutup
Skip to content

Commit 03c8e74

Browse files
committed
fix(element_injector): do not throw when cannot find element when trying to report an error
1 parent 70792c7 commit 03c8e74

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

modules/angular2/src/core/compiler/element_injector.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -496,8 +496,10 @@ export class ElementInjector extends TreeNode<ElementInjector> implements Depend
496496

497497
private _debugContext(): any {
498498
var p = this._preBuiltObjects;
499-
return new _Context(p.elementRef.nativeElement, p.view.getHostElement().nativeElement,
500-
this._injector);
499+
var element = isPresent(p.elementRef) ? p.elementRef.nativeElement : null;
500+
var hostRef = p.view.getHostElement();
501+
var componentElement = isPresent(hostRef) ? hostRef.nativeElement : null;
502+
return new _Context(element, componentElement, this._injector);
501503
}
502504

503505
private _reattachInjectors(imperativelyCreatedInjector: Injector): void {

0 commit comments

Comments
 (0)
X Tutup