From 50f7ab2a063768e32430d07fe3a8226211394cb1 Mon Sep 17 00:00:00 2001 From: Marc Laval Date: Wed, 27 Mar 2019 10:48:45 +0100 Subject: [PATCH] fix(ivy): debug element should support components with ViewContainerRef (#29534) PR Close #29534 --- packages/core/src/debug/debug_node.ts | 5 ++--- packages/core/test/debug/debug_node_spec.ts | 13 +++++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/packages/core/src/debug/debug_node.ts b/packages/core/src/debug/debug_node.ts index 52044fe16f..695ae04341 100644 --- a/packages/core/src/debug/debug_node.ts +++ b/packages/core/src/debug/debug_node.ts @@ -403,9 +403,8 @@ function _queryAllR3( elementsOnly: boolean) { const context = loadLContext(parentElement.nativeNode) !; const parentTNode = context.lView[TVIEW].data[context.nodeIndex] as TNode; - // This the fixture's debug element, so this is always a component view. - const lView = context.lView[parentTNode.index]; - const tNode = lView[TVIEW].firstChild; + const lView = getComponentViewByIndex(parentTNode.index, context.lView); + const tNode = lView[TVIEW].firstChild !; _queryNodeChildrenR3(tNode, lView, predicate, matches, elementsOnly); } diff --git a/packages/core/test/debug/debug_node_spec.ts b/packages/core/test/debug/debug_node_spec.ts index 54713b2019..89e07cca1f 100644 --- a/packages/core/test/debug/debug_node_spec.ts +++ b/packages/core/test/debug/debug_node_spec.ts @@ -190,6 +190,11 @@ class HostClassBindingCmp { hostClasses = 'class-one class-two'; } +@Component({selector: 'test-cmpt-vcref', template: `
`}) +class TestCmptWithViewContainerRef { + constructor(private vcref: ViewContainerRef) {} +} + { describe('debug element', () => { let fixture: ComponentFixture; @@ -211,6 +216,7 @@ class HostClassBindingCmp { BankAccount, TestCmpt, HostClassBindingCmp, + TestCmptWithViewContainerRef, SimpleContentComp, ], providers: [Logger], @@ -631,5 +637,12 @@ class HostClassBindingCmp { getDOM().remove(content); }); + it('should support components with ViewContainerRef', () => { + fixture = TestBed.createComponent(TestCmptWithViewContainerRef); + + const divEl = fixture.debugElement.query(By.css('div')); + expect(divEl).not.toBeNull(); + }); + }); }