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

Function navigateBetween

packages/core/src/hydration/node_lookup_utils.ts:265–289  ·  view source on GitHub ↗
(start: Node, finish: Node)

Source from the content-addressed store, hash-verified

263 * and `.nextSibling` operations.
264 */
265export function navigateBetween(start: Node, finish: Node): NodeNavigationStep[] | null {
266 if (start === finish) {
267 return [];
268 } else if (start.parentElement == null || finish.parentElement == null) {
269 return null;
270 } else if (start.parentElement === finish.parentElement) {
271 return navigateBetweenSiblings(start, finish);
272 } else {
273 // `finish` is a child of its parent, so the parent will always have a child.
274 const parent = finish.parentElement!;
275
276 const parentPath = navigateBetween(start, parent);
277 const childPath = navigateBetween(parent.firstChild!, finish);
278 if (!parentPath || !childPath) return null;
279
280 return [
281 // First navigate to `finish`'s parent
282 ...parentPath,
283 // Then to its first child.
284 NODE_NAVIGATION_STEP_FIRST_CHILD,
285 // And finally from that node to `finish` (maybe a no-op if we're already there).
286 ...childPath,
287 ];
288 }
289}
290
291/**
292 * Calculates a path between 2 sibling nodes (generates a number of `NextSibling` navigations).

Callers 1

calcPathBetweenFunction · 0.85

Calls 1

navigateBetweenSiblingsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…