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

Function navigateBetweenSiblings

packages/core/src/hydration/node_lookup_utils.ts:327–337  ·  view source on GitHub ↗

* Calculates a path between 2 sibling nodes (generates a number of `NextSibling` navigations). * Returns `null` if no such path exists between the given nodes.

(start: Node, finish: Node)

Source from the content-addressed store, hash-verified

325 * Returns `null` if no such path exists between the given nodes.
326 */
327function navigateBetweenSiblings(start: Node, finish: Node): NodeNavigationStep[] | null {
328 const nav: NodeNavigationStep[] = [];
329 let node: Node | null = null;
330 for (node = start; node != null && node !== finish; node = node.nextSibling) {
331 nav.push(NODE_NAVIGATION_STEP_NEXT_SIBLING);
332 }
333 // If the `node` becomes `null` or `undefined` at the end, that means that we
334 // didn't find the `end` node, thus return `null` (which would trigger serialization
335 // error to be produced).
336 return node == null ? null : nav;
337}
338
339/**
340 * Calculates a path between 2 nodes in terms of `nextSibling` and `firstChild`

Callers 1

navigateBetweenFunction · 0.85

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected