(skip: number, from: RNode)
| 182 | * Skips over a specified number of nodes and returns the next sibling node after that. |
| 183 | */ |
| 184 | export function siblingAfter<T extends RNode>(skip: number, from: RNode): T | null { |
| 185 | let currentNode = from; |
| 186 | for (let i = 0; i < skip; i++) { |
| 187 | ngDevMode && validateSiblingNodeExists(currentNode); |
| 188 | // `validateSiblingNodeExists` above would normally catch a missing sibling too, but it's |
| 189 | // dev-mode only. Guard against it here so production throws a coded RuntimeError instead |
| 190 | // of a raw TypeError when dereferencing `currentNode` below. |
| 191 | if (currentNode == null) { |
| 192 | throw new RuntimeError( |
| 193 | RuntimeErrorCode.HYDRATION_MISSING_SIBLINGS, |
| 194 | ngDevMode && |
| 195 | 'During hydration Angular expected more sibling nodes to be present. This usually means the client-rendered DOM no longer matches the server-rendered HTML.', |
| 196 | ); |
| 197 | } |
| 198 | currentNode = currentNode.nextSibling!; |
| 199 | } |
| 200 | return currentNode as T; |
| 201 | } |
| 202 | |
| 203 | /** |
| 204 | * Helper function to produce a string representation of the navigation steps |
no test coverage detected