mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
refactor(core): store segment heads for empty comtainers (#49455)
This commit updates the logic to store references to the comment (anchor) node as a segment head, when a container is empty (no views). Previously, the logic verified whether a container is non-empty and only stored segment head in this case. The problem is that the ViewContainerRef later on uses the segment head to start the DOM lookup and as a result, the process can not be started, since we have `null`. Now the segment head reference would point to a comment node (the anchor node) and ViewContainerRef would be able to start the lookup process. For empty views, the segment head would become an anchor of the container (which is exactly what we need). PR Close #49455
This commit is contained in:
committed by
Pawel Kozlowski
parent
ced237693a
commit
f30a4072cd
@@ -186,10 +186,7 @@ function locateOrCreateElementContainerNode(
|
||||
'Unexpected state: hydrating an <ng-container>, ' +
|
||||
'but no hydration info is available.');
|
||||
|
||||
// If this container is non-empty, store the first node as a segment head,
|
||||
// otherwise, this node is an anchor and segment head doesn't exist (thus `null`).
|
||||
const segmentHead = ngContainerSize > 0 ? currentRNode : null;
|
||||
setSegmentHead(hydrationInfo, index, segmentHead);
|
||||
setSegmentHead(hydrationInfo, index, currentRNode);
|
||||
comment = siblingAfter<RComment>(ngContainerSize, currentRNode)!;
|
||||
|
||||
if (ngDevMode) {
|
||||
|
||||
@@ -140,11 +140,8 @@ function locateOrCreateContainerAnchorImpl(
|
||||
const currentRNode = locateNextRNode(hydrationInfo, tView, lView, tNode)!;
|
||||
ngDevMode && validateNodeExists(currentRNode);
|
||||
|
||||
setSegmentHead(hydrationInfo, index, currentRNode);
|
||||
const viewContainerSize = calcSerializedContainerSize(hydrationInfo, index);
|
||||
// If this container is non-empty, store the first node as a segment head,
|
||||
// otherwise, this node is an anchor and segment head doesn't exist (thus `null`).
|
||||
const segmentHead = viewContainerSize > 0 ? currentRNode : null;
|
||||
setSegmentHead(hydrationInfo, index, segmentHead);
|
||||
const comment = siblingAfter<RComment>(viewContainerSize, currentRNode)!;
|
||||
|
||||
if (ngDevMode) {
|
||||
|
||||
Reference in New Issue
Block a user