* 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)
| 293 | * Returns `null` if no such path exists between the given nodes. |
| 294 | */ |
| 295 | function 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` |
no test coverage detected
searching dependent graphs…