fix(ivy): properly find RNode (#23193)
As we no longer create native (RNode) comment nodes for containers, we need to execute logic for finding a next sibiling node with RNode when inserting a view. The mentioned logic need to be updated for the case of dynamically created containers (LContainerNode). Indeed, we need to be able to descend into dynamically inserted views while looking for a RNode. To achieve this we need to have a pointer from a host LNode to a dynamically created LContainerNode). PR Close #23193
This commit is contained in:

committed by
Igor Minar

parent
5cd36c7764
commit
d80e9304c6
@ -556,10 +556,12 @@ export function getOrCreateContainerRef(di: LInjector): viewEngine_ViewContainer
|
||||
|
||||
ngDevMode && assertNodeOfPossibleTypes(vcRefHost, LNodeType.Container, LNodeType.Element);
|
||||
|
||||
const lContainer = createLContainer(vcRefHost.parent !, vcRefHost.view, undefined, vcRefHost);
|
||||
const lContainer = createLContainer(vcRefHost.parent !, vcRefHost.view);
|
||||
const lContainerNode: LContainerNode = createLNodeObject(
|
||||
LNodeType.Container, vcRefHost.view, vcRefHost.parent !, undefined, lContainer, null);
|
||||
|
||||
vcRefHost.dynamicLContainerNode = lContainerNode;
|
||||
|
||||
addToViewTree(vcRefHost.view, lContainer);
|
||||
|
||||
di.viewContainerRef = new ViewContainerRef(lContainerNode);
|
||||
@ -608,6 +610,10 @@ class ViewContainerRef implements viewEngine_ViewContainerRef {
|
||||
const adjustedIdx = this._adjustAndAssertIndex(index);
|
||||
|
||||
insertView(this._lContainerNode, lViewNode, adjustedIdx);
|
||||
// invalidate cache of next sibling RNode (we do similar operation in the containerRefreshEnd
|
||||
// instruction)
|
||||
this._lContainerNode.native = undefined;
|
||||
|
||||
this._viewRefs.splice(adjustedIdx, 0, viewRef);
|
||||
|
||||
(lViewNode as{parent: LNode}).parent = this._lContainerNode;
|
||||
|
Reference in New Issue
Block a user