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

Function navigateBetweenSiblings

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

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