* 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)[])
| 211 | * using provided set of navigation instructions (within `path` argument). |
| 212 | */ |
| 213 | function 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 |
no test coverage detected
searching dependent graphs…