diff --git a/packages/core/src/render3/context_discovery.ts b/packages/core/src/render3/context_discovery.ts
index feafb9be59..47a1ea1350 100644
--- a/packages/core/src/render3/context_discovery.ts
+++ b/packages/core/src/render3/context_discovery.ts
@@ -299,11 +299,15 @@ export function discoverLocalRefs(lView: LView, nodeIndex: number): {[key: strin
const tNode = lView[TVIEW].data[nodeIndex] as TNode;
if (tNode && tNode.localNames) {
const result: {[key: string]: any} = {};
- for (let i = 0; i < tNode.localNames.length; i += 2) {
+ let localIndex = tNode.index + 1;
+ for (let i = 0; i < tNode.localNames.length; i += 2, localIndex++) {
const localRefName = tNode.localNames[i];
const directiveIndex = tNode.localNames[i + 1] as number;
- result[localRefName] =
- directiveIndex === -1 ? getNativeByTNode(tNode, lView) ! : lView[directiveIndex];
+ if (directiveIndex === -1) {
+ result[localRefName] = lView[localIndex] || getNativeByTNode(tNode, lView);
+ } else {
+ result[localRefName] = lView[directiveIndex];
+ }
}
return result;
}
diff --git a/packages/core/test/linker/integration_spec.ts b/packages/core/test/linker/integration_spec.ts
index 74726f2bf4..1e6badf7a2 100644
--- a/packages/core/test/linker/integration_spec.ts
+++ b/packages/core/test/linker/integration_spec.ts
@@ -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: ''}})
- .createComponent(MyComp);
+ it('should assign the TemplateRef to a user-defined variable', () => {
+ const fixture =
+ TestBed.configureTestingModule({declarations: [MyComp]})
+ .overrideComponent(
+ MyComp, {set: {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]});