refactor(ivy): add tNodes for view nodes and hosts (#24113)
PR Close #24113
This commit is contained in:

committed by
Matias Niemelä

parent
13cb75da8b
commit
8216657681
@ -19,7 +19,7 @@ import {EmbeddedViewRef as viewEngine_EmbeddedViewRef, ViewRef as viewEngine_Vie
|
||||
import {Type} from '../type';
|
||||
|
||||
import {assertGreaterThan, assertLessThan, assertNotNull} from './assert';
|
||||
import {addToViewTree, assertPreviousIsParent, createLContainer, createLNodeObject, createTView, getDirectiveInstance, getPreviousOrParentNode, getRenderer, isComponent, renderEmbeddedTemplate, resolveDirective} from './instructions';
|
||||
import {addToViewTree, assertPreviousIsParent, createLContainer, createLNodeObject, createTNode, createTView, getDirectiveInstance, getPreviousOrParentNode, getRenderer, isComponent, renderEmbeddedTemplate, resolveDirective} from './instructions';
|
||||
import {ComponentTemplate, DirectiveDef, DirectiveDefList, PipeDefList} from './interfaces/definition';
|
||||
import {LInjector} from './interfaces/injector';
|
||||
import {LContainerNode, LElementNode, LNode, LNodeType, LViewNode, TNodeFlags} from './interfaces/node';
|
||||
@ -254,7 +254,7 @@ export function injectAttribute(attrName: string): string|undefined {
|
||||
ngDevMode && assertPreviousIsParent();
|
||||
const lElement = getPreviousOrParentNode() as LElementNode;
|
||||
ngDevMode && assertNodeType(lElement, LNodeType.Element);
|
||||
const tElement = lElement.tNode !;
|
||||
const tElement = lElement.tNode;
|
||||
ngDevMode && assertNotNull(tElement, 'expecting tNode');
|
||||
const attrs = tElement.attrs;
|
||||
if (attrs) {
|
||||
@ -278,7 +278,7 @@ export function getOrCreateChangeDetectorRef(
|
||||
if (di.changeDetectorRef) return di.changeDetectorRef;
|
||||
|
||||
const currentNode = di.node;
|
||||
if (isComponent(currentNode.tNode !)) {
|
||||
if (isComponent(currentNode.tNode)) {
|
||||
return di.changeDetectorRef = createViewRef(currentNode.data as LView, context);
|
||||
} else if (currentNode.type === LNodeType.Element) {
|
||||
return di.changeDetectorRef = getOrCreateHostChangeDetector(currentNode.view.node);
|
||||
@ -298,7 +298,7 @@ function getOrCreateHostChangeDetector(currentNode: LViewNode | LElementNode):
|
||||
createViewRef(
|
||||
hostNode.data as LView,
|
||||
hostNode.view
|
||||
.directives ![hostNode.tNode !.flags >> TNodeFlags.DirectiveStartingIndexShift]);
|
||||
.directives ![hostNode.tNode.flags >> TNodeFlags.DirectiveStartingIndexShift]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -361,7 +361,7 @@ export function getOrCreateInjectable<T>(
|
||||
// At this point, we have an injector which *may* contain the token, so we step through the
|
||||
// directives associated with the injector's corresponding node to get the directive instance.
|
||||
const node = injector.node;
|
||||
const nodeFlags = node.tNode !.flags;
|
||||
const nodeFlags = node.tNode.flags;
|
||||
const count = nodeFlags & TNodeFlags.DirectiveCountMask;
|
||||
|
||||
if (count !== 0) {
|
||||
@ -572,8 +572,12 @@ export function getOrCreateContainerRef(di: LInjector): viewEngine_ViewContainer
|
||||
const lContainerNode: LContainerNode = createLNodeObject(
|
||||
LNodeType.Container, vcRefHost.view, vcRefHost.parent !, undefined, lContainer, null);
|
||||
|
||||
// TODO(kara): Separate into own TNode when moving parent/child properties
|
||||
lContainerNode.tNode = vcRefHost.tNode;
|
||||
const hostTNode = vcRefHost.tNode;
|
||||
if (!hostTNode.dynamicContainerNode) {
|
||||
hostTNode.dynamicContainerNode = createTNode(hostTNode.index, null, null, null);
|
||||
}
|
||||
|
||||
lContainerNode.tNode = hostTNode.dynamicContainerNode;
|
||||
vcRefHost.dynamicLContainerNode = lContainerNode;
|
||||
|
||||
addToViewTree(vcRefHost.view, lContainer);
|
||||
@ -699,7 +703,7 @@ export function getOrCreateTemplateRef<T>(di: LInjector): viewEngine_TemplateRef
|
||||
if (!di.templateRef) {
|
||||
ngDevMode && assertNodeType(di.node, LNodeType.Container);
|
||||
const hostNode = di.node as LContainerNode;
|
||||
const hostTNode = hostNode.tNode !;
|
||||
const hostTNode = hostNode.tNode;
|
||||
const hostTView = hostNode.view.tView;
|
||||
if (!hostTNode.tViews) {
|
||||
hostTNode.tViews = createTView(hostTView.directiveRegistry, hostTView.pipeRegistry);
|
||||
|
Reference in New Issue
Block a user