fix(ivy): debug node references not returning template ref (#28101)

Fixes the `DebugNode.references` returning a reference to the underlying comment node, rather than the `TemplateRef` that the reference is pointing to. The issue comes from the fact that `discoverLocalRefs` falls back directly to returning the native node, if the ref isn't pointing to a directive, rather than looking through the locals.

These changes resolve FW-870.

PR Close #28101
This commit is contained in:
Kristiyan Kostadinov
2019-01-12 13:59:11 +01:00
committed by Andrew Kushnir
parent fa53150692
commit b6510a320b
2 changed files with 16 additions and 14 deletions

View File

@ -541,18 +541,16 @@ function declareTests(config?: {useJit: boolean}) {
expect(value.tagName.toLowerCase()).toEqual('div');
});
fixmeIvy(
'FW-870: DebugNode.references gets comment node instead of TemplateRef for template nodes')
.it('should assign the TemplateRef to a user-defined variable', () => {
const fixture =
TestBed.configureTestingModule({declarations: [MyComp]})
.overrideComponent(
MyComp, {set: {template: '<ng-template ref-alice></ng-template>'}})
.createComponent(MyComp);
it('should assign the TemplateRef to a user-defined variable', () => {
const fixture =
TestBed.configureTestingModule({declarations: [MyComp]})
.overrideComponent(
MyComp, {set: {template: '<ng-template ref-alice></ng-template>'}})
.createComponent(MyComp);
const value = fixture.debugElement.childNodes[0].references !['alice'];
expect(value.createEmbeddedView).toBeTruthy();
});
const value = fixture.debugElement.childNodes[0].references !['alice'];
expect(value.createEmbeddedView).toBeTruthy();
});
it('should preserve case', () => {
TestBed.configureTestingModule({declarations: [MyComp, ChildComp]});