( node: RNode | null, lView: LView | null = null, tNode: TNode | null = null, )
| 141 | * Validates that a node exists or throws |
| 142 | */ |
| 143 | export function validateNodeExists( |
| 144 | node: RNode | null, |
| 145 | lView: LView | null = null, |
| 146 | tNode: TNode | null = null, |
| 147 | ): void { |
| 148 | if (!node) { |
| 149 | const header = |
| 150 | 'During hydration, Angular expected an element to be present at this location.\n\n'; |
| 151 | let expected = ''; |
| 152 | let footer = ''; |
| 153 | if (lView !== null && tNode !== null) { |
| 154 | expected = describeExpectedDom(lView, tNode, false); |
| 155 | footer = getHydrationErrorFooter(); |
| 156 | |
| 157 | // Since the node is missing, we use the closest node to attach the error to |
| 158 | markRNodeAsHavingHydrationMismatch(unwrapRNode(lView[HOST]!), expected, ''); |
| 159 | } |
| 160 | |
| 161 | throw new RuntimeError( |
| 162 | RuntimeErrorCode.HYDRATION_MISSING_NODE, |
| 163 | `${header}${expected}\n\n${footer}`, |
| 164 | ); |
| 165 | } |
| 166 | } |
| 167 | |
| 168 | /** |
| 169 | * Builds the hydration error message when a node is not found |
no test coverage detected
searching dependent graphs…