Calls onDestroy hooks for this view
(tView: TView, lView: LView)
| 429 | |
| 430 | /** Calls onDestroy hooks for this view */ |
| 431 | function executeOnDestroys(tView: TView, lView: LView): void { |
| 432 | ngDevMode && assertNotReactive(executeOnDestroys.name); |
| 433 | let destroyHooks: DestroyHookData | null; |
| 434 | |
| 435 | if (tView != null && (destroyHooks = tView.destroyHooks) != null) { |
| 436 | for (let i = 0; i < destroyHooks.length; i += 2) { |
| 437 | const context = lView[destroyHooks[i] as number]; |
| 438 | |
| 439 | // Only call the destroy hook if the context has been requested. |
| 440 | if (!(context instanceof NodeInjectorFactory)) { |
| 441 | const toCall = destroyHooks[i + 1] as HookFn | HookData; |
| 442 | |
| 443 | if (Array.isArray(toCall)) { |
| 444 | for (let j = 0; j < toCall.length; j += 2) { |
| 445 | const callContext = context[toCall[j] as number]; |
| 446 | const hook = toCall[j + 1] as HookFn; |
| 447 | profiler(ProfilerEvent.LifecycleHookStart, callContext, hook); |
| 448 | try { |
| 449 | hook.call(callContext); |
| 450 | } finally { |
| 451 | profiler(ProfilerEvent.LifecycleHookEnd, callContext, hook); |
| 452 | } |
| 453 | } |
| 454 | } else { |
| 455 | profiler(ProfilerEvent.LifecycleHookStart, context, toCall); |
| 456 | try { |
| 457 | toCall.call(context); |
| 458 | } finally { |
| 459 | profiler(ProfilerEvent.LifecycleHookEnd, context, toCall); |
| 460 | } |
| 461 | } |
| 462 | } |
| 463 | } |
| 464 | } |
| 465 | } |
| 466 | |
| 467 | /** |
| 468 | * Returns a native element if a node can be inserted into the given parent. |
no test coverage detected
searching dependent graphs…