refactor(ivy): LContainers should store views not nodes (#25933)

PR Close #25933
This commit is contained in:
Kara Erickson
2018-09-12 08:47:03 -07:00
committed by Ben Lesh
parent a09c3923db
commit 47f4412650
5 changed files with 53 additions and 58 deletions

View File

@ -136,6 +136,7 @@ export class ComponentFactory<T> extends viewEngine_ComponentFactory<T> {
// Create element node at index 0 in data array
elementNode = hostElement(componentTag, hostNode, this.componentDef);
const componentView = elementNode.data as LViewData;
// Create directive instance with factory() and store at index 0 in directives array
component =
@ -144,8 +145,8 @@ export class ComponentFactory<T> extends viewEngine_ComponentFactory<T> {
queueHostBindingForCheck(0, this.componentDef.hostVars);
}
rootContext.components.push(component);
initChangeDetectorIfExisting(elementNode.nodeInjector, component, elementNode.data !);
(elementNode.data as LViewData)[CONTEXT] = component;
initChangeDetectorIfExisting(elementNode.nodeInjector, component, componentView);
componentView[CONTEXT] = component;
// TODO: should LifecycleHooksFeature and other host features be generated by the compiler and
// executed here?
// Angular 5 reference: https://stackblitz.com/edit/lifecycle-hooks-vcref
@ -178,8 +179,8 @@ export class ComponentFactory<T> extends viewEngine_ComponentFactory<T> {
}
// Execute the template in creation mode only, and then turn off the CreationMode flag
renderEmbeddedTemplate(elementNode, elementNode.data ![TVIEW], component, RenderFlags.Create);
elementNode.data ![FLAGS] &= ~LViewFlags.CreationMode;
renderEmbeddedTemplate(componentView, componentView[TVIEW], component, RenderFlags.Create);
componentView[FLAGS] &= ~LViewFlags.CreationMode;
} finally {
enterView(oldView, null);
if (rendererFactory.end) rendererFactory.end();