Repository navigation
fix(ivy): expose module injector ivy's TestBed impl - #25685
pkozlowski-opensource wants to merge 1 commit into
Conversation
|
You can preview f5d6b68 at https://pr25685-f5d6b68.ngbuilds.io/. |
f5d6b68 to
90f9ec0
Compare
|
You can preview 90f9ec0 at https://pr25685-90f9ec0.ngbuilds.io/. |
| constructor(private moduleInjector: Injector, private viewData: LViewData|null) { | ||
| // viewData can be null for the root element created to contain test component (such element is | ||
| // created before ivy kicks in and creates root view). | ||
| this.nodeIndex = viewData ? viewData.length - 1 : null; |
There was a problem hiding this comment.
This is WRONG as reading length of the viewData does NOT get us index of where the corresponding LNode will be stored. Needs design discussion with @mhevery
There was a problem hiding this comment.
Would this help:
angular/packages/core/src/render3/element_discovery.ts
Lines 39 to 66 in 29761ea
| const wrapper = ngModule.injector.get(WRAP_RENDERER_FACTORY2, (v: RendererFactory2) => v); | ||
| rendererFactory = wrapper(ngModule.injector.get(RendererFactory2)) as RendererFactory3; | ||
| const wrapper = | ||
| ngModule.injector.get(WRAP_RENDERER_FACTORY2, (v: RendererFactory2, i: Injector) => v); |
There was a problem hiding this comment.
My current thinking is that WRAP_RENDERER_FACTORY2 should be reverted since with element_discovery we don't need it.
What we should do is to change
angular/packages/core/src/debug/debug_node.ts
Lines 167 to 169 in 29761ea
ng_ivy_switch.ts so that in case of Ivy it returns DebugNode implementation which knows how to use angular/packages/core/src/render3/element_discovery.ts
Lines 39 to 66 in 29761ea
There was a problem hiding this comment.
@mhevery I fully agree with the general idea of using element discovery to "enrich" native node with debug context for TestBed.
In the details, though, I don't think we can simply plug into
angular/packages/core/src/debug/debug_node.ts
Lines 167 to 169 in 29761ea
- at this point we don't know the type of native node (element / text / comment) and we need to know this in order to instantiate DebugNode or DebugElement
- we don't have enough context to constructs any of those classes (ex. listeners, properties etc.)
My thinking is that we will have to call indexDebugNode from ivy instructions - unless we want to do deeper breaking changes to the TestBed.
The challenge to call indexDebugNode would be to do this in the tree-shakable way (do so only in the debug mode?).
Let's discuss more today.
|
Closing in favour of #26211 |
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
This PR changes the ivy's TestBed implementation - previously no injector was available for the root node (one created to contain test component). Now such node gets module injector.
This change unblocks some of the tests for
ngTemplateOutlet.