fix(ivy): get name directly from nativeNode (#32198)

nativeElement can return null so an error can occur when accessing
nodeName from nativeElement.

PR Close #32198
This commit is contained in:
Andrew Scott
2019-08-19 15:04:42 -07:00
committed by Andrew Kushnir
parent cfed0c0cf1
commit 3dbc4ab572
2 changed files with 19 additions and 1 deletions

View File

@ -1018,4 +1018,22 @@ class TestCmptWithPropBindings {
});
});
it('should not error when accessing node name', () => {
@Component({template: ''})
class EmptyComponent {
}
const fixture = TestBed.configureTestingModule({declarations: [EmptyComponent]})
.createComponent(EmptyComponent);
let node = fixture.debugElement;
let superParentName = '';
// Traverse upwards, all the way to #document, which is not a
// Node.ELEMENT_NODE
while (node) {
superParentName = node.name;
node = node.parent !;
}
expect(superParentName).not.toEqual('');
});
}