Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion packages/core/src/debug/debug_node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,17 @@ 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.nativeNode.nodeName; }
get name(): string {
try {
const context = loadLContext(this.nativeNode) !;
const lView = context.lView;
const tData = lView[TVIEW].data;
const tNode = tData[context.nodeIndex] as TNode;
return tNode.tagName !;
} catch (e) {
return this.nativeNode.nodeName;
}
}

/**
* Gets a map of property names to property values for an element.
Expand Down
15 changes: 15 additions & 0 deletions packages/core/test/debug/debug_node_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1036,4 +1036,19 @@ class TestCmptWithPropBindings {
}
expect(superParentName).not.toEqual('');
});

it('should match node name with declared casing', () => {
@Component({template: `<div></div><myComponent></myComponent>`})
class Wrapper {
}

@Component({selector: 'myComponent', template: ''})
class MyComponent {
}

const fixture = TestBed.configureTestingModule({declarations: [Wrapper, MyComponent]})
.createComponent(Wrapper);
expect(fixture.debugElement.query(e => e.name === 'myComponent')).toBeTruthy();
expect(fixture.debugElement.query(e => e.name === 'div')).toBeTruthy();
});
}