MCPcopy Create free account
hub / github.com/angular/angular / siblingAfter

Function siblingAfter

packages/core/src/hydration/node_lookup_utils.ts:185–202  ·  view source on GitHub ↗
(skip: number, from: RNode)

Source from the content-addressed store, hash-verified

183 * Skips over a specified number of nodes and returns the next sibling node after that.
184 */
185export function siblingAfter<T extends RNode>(skip: number, from: RNode): T | null {
186 let currentNode = from;
187 for (let i = 0; i < skip; i++) {
188 ngDevMode && validateSiblingNodeExists(currentNode);
189 // `validateSiblingNodeExists` above would normally catch a missing sibling too, but it's
190 // dev-mode only. Guard against it here so production throws a coded RuntimeError instead
191 // of a raw TypeError when dereferencing `currentNode` below.
192 if (currentNode == null) {
193 throw new RuntimeError(
194 RuntimeErrorCode.HYDRATION_MISSING_SIBLINGS,
195 ngDevMode &&
196 'During hydration Angular expected more sibling nodes to be present. This usually means the client-rendered DOM no longer matches the server-rendered HTML.',
197 );
198 }
199 currentNode = getNextSibling(currentNode as Node)!;
200 }
201 return currentNode as T;
202}
203
204/**
205 * Helper function to produce a string representation of the navigation steps

Calls 2

getNextSiblingFunction · 0.90

Tested by

no test coverage detected