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

Function navigateToNode

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

* Helper function that navigates from a starting point node (the `from` node) * using provided set of navigation instructions (within `path` argument).

(from: Node, instructions: (number | NodeNavigationStep)[])

Source from the content-addressed store, hash-verified

211 * using provided set of navigation instructions (within `path` argument).
212 */
213function navigateToNode(from: Node, instructions: (number | NodeNavigationStep)[]): RNode {
214 let node = from;
215 for (let i = 0; i < instructions.length; i += 2) {
216 const step = instructions[i];
217 const repeat = instructions[i + 1] as number;
218 for (let r = 0; r < repeat; r++) {
219 if (ngDevMode && !node) {
220 throw nodeNotFoundAtPathError(from, stringifyNavigationInstructions(instructions));
221 }
222 switch (step) {
223 case NODE_NAVIGATION_STEP_FIRST_CHILD:
224 node = node.firstChild!;
225 break;
226 case NODE_NAVIGATION_STEP_NEXT_SIBLING:
227 node = node.nextSibling!;
228 break;
229 }
230 }
231 }
232 if (ngDevMode && !node) {
233 throw nodeNotFoundAtPathError(from, stringifyNavigationInstructions(instructions));
234 }
235 return node as RNode;
236}
237
238/**
239 * Locates an RNode given a set of navigation instructions (which also contains

Callers 1

locateRNodeByPathFunction · 0.85

Calls 2

nodeNotFoundAtPathErrorFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…