* Calls lifecycle hooks with their contexts, skipping init hooks if it's not * the first LView pass * * @param currentView The current view * @param arr The array in which the hooks are found * @param initPhaseState the current state of the init phase * @param currentNodeIndex 3 cases dependin
( currentView: LView, arr: HookData, initPhase: InitPhaseState, currentNodeIndex: number | null | undefined, )
| 236 | * case, when executing select(number)) |
| 237 | */ |
| 238 | function callHooks( |
| 239 | currentView: LView, |
| 240 | arr: HookData, |
| 241 | initPhase: InitPhaseState, |
| 242 | currentNodeIndex: number | null | undefined, |
| 243 | ): void { |
| 244 | ngDevMode && |
| 245 | assertEqual( |
| 246 | isInCheckNoChangesMode(), |
| 247 | false, |
| 248 | 'Hooks should never be run when in check no changes mode.', |
| 249 | ); |
| 250 | const startIndex = |
| 251 | currentNodeIndex !== undefined |
| 252 | ? currentView[PREORDER_HOOK_FLAGS] & PreOrderHookFlags.IndexOfTheNextPreOrderHookMaskMask |
| 253 | : 0; |
| 254 | const nodeIndexLimit = currentNodeIndex != null ? currentNodeIndex : -1; |
| 255 | const max = arr.length - 1; // Stop the loop at length - 1, because we look for the hook at i + 1 |
| 256 | let lastNodeIndexFound = 0; |
| 257 | for (let i = startIndex; i < max; i++) { |
| 258 | const hook = arr[i + 1] as number | (() => void); |
| 259 | if (typeof hook === 'number') { |
| 260 | lastNodeIndexFound = arr[i] as number; |
| 261 | if (currentNodeIndex != null && lastNodeIndexFound >= currentNodeIndex) { |
| 262 | break; |
| 263 | } |
| 264 | } else { |
| 265 | const isInitHook = (arr[i] as number) < 0; |
| 266 | if (isInitHook) { |
| 267 | currentView[PREORDER_HOOK_FLAGS] += PreOrderHookFlags.NumberOfInitHooksCalledIncrementer; |
| 268 | } |
| 269 | if (lastNodeIndexFound < nodeIndexLimit || nodeIndexLimit == -1) { |
| 270 | callHook(currentView, initPhase, arr, i); |
| 271 | currentView[PREORDER_HOOK_FLAGS] = |
| 272 | (currentView[PREORDER_HOOK_FLAGS] & PreOrderHookFlags.NumberOfInitHooksCalledMask) + |
| 273 | i + |
| 274 | 2; |
| 275 | } |
| 276 | i++; |
| 277 | } |
| 278 | } |
| 279 | } |
| 280 | |
| 281 | /** |
| 282 | * Executes a single lifecycle hook, making sure that: |
no test coverage detected
searching dependent graphs…