refactor(ivy): save check methods separately (#21795) (#21905)

PR Close #21795

PR Close #21905
This commit is contained in:
Kara Erickson
2018-01-25 20:41:57 -08:00
committed by Jason Aden
parent 81306c1f61
commit 9dca5f2743
6 changed files with 73 additions and 77 deletions

View File

@ -21,7 +21,7 @@ import {isNodeMatchingSelector} from './node_selector_matcher';
import {ComponentDef, ComponentTemplate, ComponentType, DirectiveDef, DirectiveType} from './interfaces/definition';
import {RElement, RText, Renderer3, RendererFactory3, ProceduralRenderer3, ObjectOrientedRenderer3, RendererStyleFlags3} from './interfaces/renderer';
import {isDifferent, stringify} from './util';
import {executeViewHooks, executeContentHooks, queueLifecycleHooks, queueInitHooks, executeInitHooks} from './hooks';
import {executeHooks, executeContentHooks, queueLifecycleHooks, queueInitHooks, executeInitHooks} from './hooks';
/**
@ -151,7 +151,9 @@ export function enterView(newView: LView, host: LElementNode | LViewNode | null)
* the direction of traversal (up or down the view tree) a bit clearer.
*/
export function leaveView(newView: LView): void {
executeViewHooks(currentView);
executeHooks(
currentView.data, currentView.tView.viewHooks, currentView.tView.viewCheckHooks,
creationMode);
currentView.creationMode = false;
currentView.lifecycleStage = LifecycleStage.INIT;
currentView.tView.firstTemplatePass = false;
@ -487,8 +489,11 @@ export function createTView(): TView {
data: [],
firstTemplatePass: true,
initHooks: null,
checkHooks: null,
contentHooks: null,
contentCheckHooks: null,
viewHooks: null,
viewCheckHooks: null,
destroyHooks: null
};
}
@ -1045,7 +1050,7 @@ export function containerRefreshStart(index: number): void {
// We need to execute init hooks here so ngOnInit hooks are called in top level views
// before they are called in embedded views (for backwards compatibility).
executeInitHooks(currentView);
executeInitHooks(currentView, currentView.tView, creationMode);
}
/**
@ -1176,8 +1181,8 @@ export function viewEnd(): void {
* @param elementIndex
*/
export function componentRefresh<T>(directiveIndex: number, elementIndex: number): void {
executeInitHooks(currentView);
executeContentHooks(currentView);
executeInitHooks(currentView, currentView.tView, creationMode);
executeContentHooks(currentView, currentView.tView, creationMode);
const template = (tData[directiveIndex] as ComponentDef<T>).template;
if (template != null) {
ngDevMode && assertDataInRange(elementIndex);