diff --git a/packages/core/src/render3/instructions/element_container.ts b/packages/core/src/render3/instructions/element_container.ts index 384ba50d8c2..34f263a9d8b 100644 --- a/packages/core/src/render3/instructions/element_container.ts +++ b/packages/core/src/render3/instructions/element_container.ts @@ -186,10 +186,7 @@ function locateOrCreateElementContainerNode( 'Unexpected state: hydrating an , ' + '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(ngContainerSize, currentRNode)!; if (ngDevMode) { diff --git a/packages/core/src/render3/instructions/template.ts b/packages/core/src/render3/instructions/template.ts index 75136210fcc..a2a78ceb310 100644 --- a/packages/core/src/render3/instructions/template.ts +++ b/packages/core/src/render3/instructions/template.ts @@ -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(viewContainerSize, currentRNode)!; if (ngDevMode) {