MCPcopy Index your code
hub / github.com/angular/angular / navigateBetweenSiblings

Function navigateBetweenSiblings

packages/core/src/hydration/node_lookup_utils.ts:295–305  ·  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

293 * Returns `null` if no such path exists between the given nodes.
294 */
295function navigateBetweenSiblings(start: Node, finish: Node): NodeNavigationStep[] | null {
296 const nav: NodeNavigationStep[] = [];
297 let node: Node | null = null;
298 for (node = start; node != null && node !== finish; node = node.nextSibling) {
299 nav.push(NODE_NAVIGATION_STEP_NEXT_SIBLING);
300 }
301 // If the `node` becomes `null` or `undefined` at the end, that means that we
302 // didn't find the `end` node, thus return `null` (which would trigger serialization
303 // error to be produced).
304 return node == null ? null : nav;
305}
306
307/**
308 * 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

Used in the wild real call sites across dependent graphs

searching dependent graphs…