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:
Pawel Kozlowski
2018-04-03 10:18:25 +02:00
committed by Igor Minar
parent 5cd36c7764
commit d80e9304c6
6 changed files with 189 additions and 23 deletions

View File

@ -318,7 +318,8 @@ export function createLNodeObject(
data: state,
queries: queries,
tNode: null,
pNextOrParent: null
pNextOrParent: null,
dynamicLContainerNode: null
};
}
@ -386,6 +387,9 @@ export function createLNode(
previousOrParentNode.next,
`previousOrParentNode's next property should not have been set ${index}.`);
previousOrParentNode.next = node;
if (previousOrParentNode.dynamicLContainerNode) {
previousOrParentNode.dynamicLContainerNode.next = node;
}
}
}
previousOrParentNode = node;
@ -452,9 +456,10 @@ export function renderEmbeddedTemplate<T>(
const directives = currentView && currentView.tView.directiveRegistry;
const pipes = currentView && currentView.tView.pipeRegistry;
const view = createLView(
-1, renderer, createTView(directives, pipes), template, context, LViewFlags.CheckAlways);
viewNode = createLNode(null, LNodeType.View, null, view);
const tView = getOrCreateTView(template, directives, pipes);
const lView = createLView(-1, renderer, tView, template, context, LViewFlags.CheckAlways);
viewNode = createLNode(null, LNodeType.View, null, lView);
cm = true;
}
oldView = enterView(viewNode.data, viewNode);
@ -1311,8 +1316,7 @@ function generateInitialInputs(
export function createLContainer(
parentLNode: LNode, currentView: LView, template?: ComponentTemplate<any>,
host?: LContainerNode | LElementNode): LContainer {
parentLNode: LNode, currentView: LView, template?: ComponentTemplate<any>): LContainer {
ngDevMode && assertNotNull(parentLNode, 'containers should have a parent');
return <LContainer>{
views: [],
@ -1324,8 +1328,7 @@ export function createLContainer(
next: null,
parent: currentView,
dynamicViewCount: 0,
queries: null,
host: host == null ? null : host
queries: null
};
}