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(ivy): get name directly from nativeNode #32198

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion packages/core/src/debug/debug_node.ts
Expand Up @@ -247,7 +247,7 @@ class DebugElement__POST_R3__ extends DebugNode__POST_R3__ implements DebugEleme
return this.nativeNode.nodeType == Node.ELEMENT_NODE ? this.nativeNode as Element : null;
}

get name(): string { return this.nativeElement !.nodeName; }
get name(): string { return this.nativeNode.nodeName; }

/**
* Gets a map of property names to property values for an element.
Expand Down
18 changes: 18 additions & 0 deletions packages/core/test/debug/debug_node_spec.ts
Expand Up @@ -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('');
});
}