refactor(ivy): pass host into createLView explicitly (#28461)
`LView` `HOST` was set in most cases right after creating `LView`. This makes the API cleaner by explicitly passing it ont `createLView`. PR Close #28461
This commit is contained in:
parent
22d3226491
commit
62a13e795a
|
@ -23,7 +23,7 @@ import {ComponentDef, ComponentType, RenderFlags} from './interfaces/definition'
|
||||||
import {TElementNode, TNode, TNodeFlags, TNodeType} from './interfaces/node';
|
import {TElementNode, TNode, TNodeFlags, TNodeType} from './interfaces/node';
|
||||||
import {PlayerHandler} from './interfaces/player';
|
import {PlayerHandler} from './interfaces/player';
|
||||||
import {RElement, Renderer3, RendererFactory3, domRendererFactory3} from './interfaces/renderer';
|
import {RElement, Renderer3, RendererFactory3, domRendererFactory3} from './interfaces/renderer';
|
||||||
import {CONTEXT, FLAGS, HEADER_OFFSET, HOST, HOST_NODE, LView, LViewFlags, RootContext, RootContextFlags, TVIEW} from './interfaces/view';
|
import {CONTEXT, FLAGS, HEADER_OFFSET, HOST, LView, LViewFlags, RootContext, RootContextFlags, TVIEW, T_HOST} from './interfaces/view';
|
||||||
import {enterView, getPreviousOrParentTNode, leaveView, resetComponentState, setCurrentDirectiveDef} from './state';
|
import {enterView, getPreviousOrParentTNode, leaveView, resetComponentState, setCurrentDirectiveDef} from './state';
|
||||||
import {defaultScheduler, getRootView, readPatchedLView, renderStringify} from './util';
|
import {defaultScheduler, getRootView, readPatchedLView, renderStringify} from './util';
|
||||||
|
|
||||||
|
@ -122,8 +122,8 @@ export function renderComponent<T>(
|
||||||
|
|
||||||
const renderer = rendererFactory.createRenderer(hostRNode, componentDef);
|
const renderer = rendererFactory.createRenderer(hostRNode, componentDef);
|
||||||
const rootView: LView = createLView(
|
const rootView: LView = createLView(
|
||||||
null, createTView(-1, null, 1, 0, null, null, null), rootContext, rootFlags, rendererFactory,
|
null, createTView(-1, null, 1, 0, null, null, null), rootContext, rootFlags, null, null,
|
||||||
renderer, undefined, opts.injector || null);
|
rendererFactory, renderer, undefined, opts.injector || null);
|
||||||
|
|
||||||
const oldView = enterView(rootView, null);
|
const oldView = enterView(rootView, null);
|
||||||
let component: T;
|
let component: T;
|
||||||
|
@ -163,13 +163,13 @@ export function createRootComponentView(
|
||||||
rendererFactory: RendererFactory3, renderer: Renderer3, sanitizer?: Sanitizer | null): LView {
|
rendererFactory: RendererFactory3, renderer: Renderer3, sanitizer?: Sanitizer | null): LView {
|
||||||
resetComponentState();
|
resetComponentState();
|
||||||
const tView = rootView[TVIEW];
|
const tView = rootView[TVIEW];
|
||||||
|
const tNode: TElementNode = createNodeAtIndex(0, TNodeType.Element, rNode, null, null);
|
||||||
const componentView = createLView(
|
const componentView = createLView(
|
||||||
rootView,
|
rootView,
|
||||||
getOrCreateTView(
|
getOrCreateTView(
|
||||||
def.template, def.consts, def.vars, def.directiveDefs, def.pipeDefs, def.viewQuery),
|
def.template, def.consts, def.vars, def.directiveDefs, def.pipeDefs, def.viewQuery),
|
||||||
null, def.onPush ? LViewFlags.Dirty : LViewFlags.CheckAlways, rendererFactory, renderer,
|
null, def.onPush ? LViewFlags.Dirty : LViewFlags.CheckAlways, rootView[HEADER_OFFSET], tNode,
|
||||||
sanitizer);
|
rendererFactory, renderer, sanitizer);
|
||||||
const tNode = createNodeAtIndex(0, TNodeType.Element, rNode, null, null);
|
|
||||||
|
|
||||||
if (tView.firstTemplatePass) {
|
if (tView.firstTemplatePass) {
|
||||||
diPublicInInjector(getOrCreateNodeInjectorForNode(tNode, rootView), rootView, def.type);
|
diPublicInInjector(getOrCreateNodeInjectorForNode(tNode, rootView), rootView, def.type);
|
||||||
|
@ -179,8 +179,6 @@ export function createRootComponentView(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store component view at node index, with node as the HOST
|
// Store component view at node index, with node as the HOST
|
||||||
componentView[HOST] = rootView[HEADER_OFFSET];
|
|
||||||
componentView[HOST_NODE] = tNode as TElementNode;
|
|
||||||
return rootView[HEADER_OFFSET] = componentView;
|
return rootView[HEADER_OFFSET] = componentView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -161,7 +161,7 @@ export class ComponentFactory<T> extends viewEngine_ComponentFactory<T> {
|
||||||
|
|
||||||
// Create the root view. Uses empty TView and ContentTemplate.
|
// Create the root view. Uses empty TView and ContentTemplate.
|
||||||
const rootLView = createLView(
|
const rootLView = createLView(
|
||||||
null, createTView(-1, null, 1, 0, null, null, null), rootContext, rootFlags,
|
null, createTView(-1, null, 1, 0, null, null, null), rootContext, rootFlags, null, null,
|
||||||
rendererFactory, renderer, sanitizer, rootViewInjector);
|
rendererFactory, renderer, sanitizer, rootViewInjector);
|
||||||
|
|
||||||
// rootView is the parent when bootstrapping
|
// rootView is the parent when bootstrapping
|
||||||
|
|
|
@ -18,7 +18,7 @@ import {NG_ELEMENT_ID} from './fields';
|
||||||
import {DirectiveDef} from './interfaces/definition';
|
import {DirectiveDef} from './interfaces/definition';
|
||||||
import {NO_PARENT_INJECTOR, NodeInjectorFactory, PARENT_INJECTOR, RelativeInjectorLocation, RelativeInjectorLocationFlags, TNODE, isFactory} from './interfaces/injector';
|
import {NO_PARENT_INJECTOR, NodeInjectorFactory, PARENT_INJECTOR, RelativeInjectorLocation, RelativeInjectorLocationFlags, TNODE, isFactory} from './interfaces/injector';
|
||||||
import {AttributeMarker, TContainerNode, TElementContainerNode, TElementNode, TNode, TNodeFlags, TNodeProviderIndexes, TNodeType} from './interfaces/node';
|
import {AttributeMarker, TContainerNode, TElementContainerNode, TElementNode, TNode, TNodeFlags, TNodeProviderIndexes, TNodeType} from './interfaces/node';
|
||||||
import {DECLARATION_VIEW, HOST_NODE, INJECTOR, LView, TData, TVIEW, TView} from './interfaces/view';
|
import {DECLARATION_VIEW, INJECTOR, LView, TData, TVIEW, TView, T_HOST} from './interfaces/view';
|
||||||
import {assertNodeOfPossibleTypes} from './node_assert';
|
import {assertNodeOfPossibleTypes} from './node_assert';
|
||||||
import {getLView, getPreviousOrParentTNode, setTNodeAndViewData} from './state';
|
import {getLView, getPreviousOrParentTNode, setTNodeAndViewData} from './state';
|
||||||
import {findComponentView, getParentInjectorIndex, getParentInjectorView, hasParentInjector, isComponent, isComponentDef, renderStringify} from './util';
|
import {findComponentView, getParentInjectorIndex, getParentInjectorView, hasParentInjector, isComponent, isComponentDef, renderStringify} from './util';
|
||||||
|
@ -205,11 +205,11 @@ export function getParentInjectorLocation(tNode: TNode, view: LView): RelativeIn
|
||||||
// For most cases, the parent injector index can be found on the host node (e.g. for component
|
// For most cases, the parent injector index can be found on the host node (e.g. for component
|
||||||
// or container), so this loop will be skipped, but we must keep the loop here to support
|
// or container), so this loop will be skipped, but we must keep the loop here to support
|
||||||
// the rarer case of deeply nested <ng-template> tags or inline views.
|
// the rarer case of deeply nested <ng-template> tags or inline views.
|
||||||
let hostTNode = view[HOST_NODE];
|
let hostTNode = view[T_HOST];
|
||||||
let viewOffset = 1;
|
let viewOffset = 1;
|
||||||
while (hostTNode && hostTNode.injectorIndex === -1) {
|
while (hostTNode && hostTNode.injectorIndex === -1) {
|
||||||
view = view[DECLARATION_VIEW] !;
|
view = view[DECLARATION_VIEW] !;
|
||||||
hostTNode = view ? view[HOST_NODE] : null;
|
hostTNode = view ? view[T_HOST] : null;
|
||||||
viewOffset++;
|
viewOffset++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -332,7 +332,7 @@ export function getOrCreateInjectable<T>(
|
||||||
let injectorIndex = getInjectorIndex(tNode, lView);
|
let injectorIndex = getInjectorIndex(tNode, lView);
|
||||||
let parentLocation: RelativeInjectorLocation = NO_PARENT_INJECTOR;
|
let parentLocation: RelativeInjectorLocation = NO_PARENT_INJECTOR;
|
||||||
let hostTElementNode: TNode|null =
|
let hostTElementNode: TNode|null =
|
||||||
flags & InjectFlags.Host ? findComponentView(lView)[HOST_NODE] : null;
|
flags & InjectFlags.Host ? findComponentView(lView)[T_HOST] : null;
|
||||||
|
|
||||||
// If we should skip this injector, or if there is no injector on this node, start by
|
// If we should skip this injector, or if there is no injector on this node, start by
|
||||||
// searching
|
// searching
|
||||||
|
|
|
@ -19,7 +19,7 @@ import {TElementNode, TIcuContainerNode, TNode, TNodeType} from './interfaces/no
|
||||||
import {RComment, RElement} from './interfaces/renderer';
|
import {RComment, RElement} from './interfaces/renderer';
|
||||||
import {SanitizerFn} from './interfaces/sanitization';
|
import {SanitizerFn} from './interfaces/sanitization';
|
||||||
import {StylingContext} from './interfaces/styling';
|
import {StylingContext} from './interfaces/styling';
|
||||||
import {BINDING_INDEX, HEADER_OFFSET, HOST_NODE, LView, RENDERER, TVIEW, TView} from './interfaces/view';
|
import {BINDING_INDEX, HEADER_OFFSET, LView, RENDERER, TVIEW, TView, T_HOST} from './interfaces/view';
|
||||||
import {appendChild, createTextNode, nativeRemoveNode} from './node_manipulation';
|
import {appendChild, createTextNode, nativeRemoveNode} from './node_manipulation';
|
||||||
import {getIsParent, getLView, getPreviousOrParentTNode, setIsParent, setPreviousOrParentTNode} from './state';
|
import {getIsParent, getLView, getPreviousOrParentTNode, setIsParent, setPreviousOrParentTNode} from './state';
|
||||||
import {NO_CHANGE} from './tokens';
|
import {NO_CHANGE} from './tokens';
|
||||||
|
@ -368,9 +368,8 @@ function i18nStartFirstPass(
|
||||||
const previousOrParentTNode = getPreviousOrParentTNode();
|
const previousOrParentTNode = getPreviousOrParentTNode();
|
||||||
const parentTNode = getIsParent() ? getPreviousOrParentTNode() :
|
const parentTNode = getIsParent() ? getPreviousOrParentTNode() :
|
||||||
previousOrParentTNode && previousOrParentTNode.parent;
|
previousOrParentTNode && previousOrParentTNode.parent;
|
||||||
let parentIndex = parentTNode && parentTNode !== viewData[HOST_NODE] ?
|
let parentIndex =
|
||||||
parentTNode.index - HEADER_OFFSET :
|
parentTNode && parentTNode !== viewData[T_HOST] ? parentTNode.index - HEADER_OFFSET : index;
|
||||||
index;
|
|
||||||
let parentIndexPointer = 0;
|
let parentIndexPointer = 0;
|
||||||
parentIndexStack[parentIndexPointer] = parentIndex;
|
parentIndexStack[parentIndexPointer] = parentIndex;
|
||||||
const createOpCodes: I18nMutateOpCodes = [];
|
const createOpCodes: I18nMutateOpCodes = [];
|
||||||
|
@ -482,7 +481,7 @@ function appendI18nNode(tNode: TNode, parentTNode: TNode, previousTNode: TNode |
|
||||||
tNode.next = null;
|
tNode.next = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parentTNode !== viewData[HOST_NODE]) {
|
if (parentTNode !== viewData[T_HOST]) {
|
||||||
tNode.parent = parentTNode as TElementNode;
|
tNode.parent = parentTNode as TElementNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -665,7 +664,7 @@ function readCreateOpCodes(
|
||||||
if (destinationNodeIndex === index) {
|
if (destinationNodeIndex === index) {
|
||||||
// If the destination node is `i18nStart`, we don't have a
|
// If the destination node is `i18nStart`, we don't have a
|
||||||
// top-level node and we should use the host node instead
|
// top-level node and we should use the host node instead
|
||||||
destinationTNode = viewData[HOST_NODE] !;
|
destinationTNode = viewData[T_HOST] !;
|
||||||
} else {
|
} else {
|
||||||
destinationTNode = getTNode(destinationNodeIndex, viewData);
|
destinationTNode = getTNode(destinationNodeIndex, viewData);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,9 +30,9 @@ import {AttributeMarker, InitialInputData, InitialInputs, LocalRefExtractor, Pro
|
||||||
import {PlayerFactory} from './interfaces/player';
|
import {PlayerFactory} from './interfaces/player';
|
||||||
import {CssSelectorList, NG_PROJECT_AS_ATTR_NAME} from './interfaces/projection';
|
import {CssSelectorList, NG_PROJECT_AS_ATTR_NAME} from './interfaces/projection';
|
||||||
import {LQueries} from './interfaces/query';
|
import {LQueries} from './interfaces/query';
|
||||||
import {GlobalTargetResolver, ProceduralRenderer3, RComment, RElement, RText, Renderer3, RendererFactory3, isProceduralRenderer} from './interfaces/renderer';
|
import {GlobalTargetResolver, ProceduralRenderer3, RComment, RElement, RNode, RText, Renderer3, RendererFactory3, isProceduralRenderer} from './interfaces/renderer';
|
||||||
import {SanitizerFn} from './interfaces/sanitization';
|
import {SanitizerFn} from './interfaces/sanitization';
|
||||||
import {BINDING_INDEX, CLEANUP, CONTAINER_INDEX, CONTEXT, DECLARATION_VIEW, FLAGS, HEADER_OFFSET, HOST, HOST_NODE, INJECTOR, InitPhaseState, LView, LViewFlags, NEXT, OpaqueViewState, PARENT, QUERIES, RENDERER, RENDERER_FACTORY, RootContext, RootContextFlags, SANITIZER, TAIL, TData, TVIEW, TView} from './interfaces/view';
|
import {BINDING_INDEX, CLEANUP, CONTAINER_INDEX, CONTEXT, DECLARATION_VIEW, FLAGS, HEADER_OFFSET, HOST, INJECTOR, InitPhaseState, LView, LViewFlags, NEXT, OpaqueViewState, PARENT, QUERIES, RENDERER, RENDERER_FACTORY, RootContext, RootContextFlags, SANITIZER, TAIL, TData, TVIEW, TView, T_HOST} from './interfaces/view';
|
||||||
import {assertNodeOfPossibleTypes, assertNodeType} from './node_assert';
|
import {assertNodeOfPossibleTypes, assertNodeType} from './node_assert';
|
||||||
import {appendChild, appendProjectedNode, createTextNode, getLViewChild, insertView, removeView} from './node_manipulation';
|
import {appendChild, appendProjectedNode, createTextNode, getLViewChild, insertView, removeView} from './node_manipulation';
|
||||||
import {isNodeMatchingSelectorList, matchingSelectorIndex} from './node_selector_matcher';
|
import {isNodeMatchingSelectorList, matchingSelectorIndex} from './node_selector_matcher';
|
||||||
|
@ -156,6 +156,7 @@ function refreshChildComponents(components: number[] | null): void {
|
||||||
|
|
||||||
export function createLView<T>(
|
export function createLView<T>(
|
||||||
parentLView: LView | null, tView: TView, context: T | null, flags: LViewFlags,
|
parentLView: LView | null, tView: TView, context: T | null, flags: LViewFlags,
|
||||||
|
host: RElement | null, tHostNode: TViewNode | TElementNode | null,
|
||||||
rendererFactory?: RendererFactory3 | null, renderer?: Renderer3 | null,
|
rendererFactory?: RendererFactory3 | null, renderer?: Renderer3 | null,
|
||||||
sanitizer?: Sanitizer | null, injector?: Injector | null): LView {
|
sanitizer?: Sanitizer | null, injector?: Injector | null): LView {
|
||||||
const lView = tView.blueprint.slice() as LView;
|
const lView = tView.blueprint.slice() as LView;
|
||||||
|
@ -168,6 +169,8 @@ export function createLView<T>(
|
||||||
ngDevMode && assertDefined(lView[RENDERER], 'Renderer is required');
|
ngDevMode && assertDefined(lView[RENDERER], 'Renderer is required');
|
||||||
lView[SANITIZER] = sanitizer || parentLView && parentLView[SANITIZER] || null !;
|
lView[SANITIZER] = sanitizer || parentLView && parentLView[SANITIZER] || null !;
|
||||||
lView[INJECTOR as any] = injector || parentLView && parentLView[INJECTOR] || null;
|
lView[INJECTOR as any] = injector || parentLView && parentLView[INJECTOR] || null;
|
||||||
|
lView[HOST] = host;
|
||||||
|
lView[T_HOST] = tHostNode;
|
||||||
return lView;
|
return lView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -216,7 +219,7 @@ export function createNodeAtIndex(
|
||||||
|
|
||||||
// Parents cannot cross component boundaries because components will be used in multiple places,
|
// Parents cannot cross component boundaries because components will be used in multiple places,
|
||||||
// so it's only set if the view is the same.
|
// so it's only set if the view is the same.
|
||||||
const parentInSameView = parent && parent !== lView[HOST_NODE];
|
const parentInSameView = parent && parent !== lView[T_HOST];
|
||||||
const tParentNode = parentInSameView ? parent as TElementNode | TContainerNode : null;
|
const tParentNode = parentInSameView ? parent as TElementNode | TContainerNode : null;
|
||||||
|
|
||||||
tNode = tView.data[adjustedIndex] = createTNode(tParentNode, type, adjustedIndex, name, attrs);
|
tNode = tView.data[adjustedIndex] = createTNode(tParentNode, type, adjustedIndex, name, attrs);
|
||||||
|
@ -258,7 +261,7 @@ export function assignTViewNodeToLView(
|
||||||
TNodeType.View, index, null, null) as TViewNode;
|
TNodeType.View, index, null, null) as TViewNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
return lView[HOST_NODE] = tNode as TViewNode;
|
return lView[T_HOST] = tNode as TViewNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -306,28 +309,28 @@ export function allocExpando(view: LView, numSlotsToAlloc: number) {
|
||||||
*/
|
*/
|
||||||
export function renderTemplate<T>(
|
export function renderTemplate<T>(
|
||||||
hostNode: RElement, templateFn: ComponentTemplate<T>, consts: number, vars: number, context: T,
|
hostNode: RElement, templateFn: ComponentTemplate<T>, consts: number, vars: number, context: T,
|
||||||
providedRendererFactory: RendererFactory3, hostView: LView | null,
|
providedRendererFactory: RendererFactory3, componentView: LView | null,
|
||||||
directives?: DirectiveDefListOrFactory | null, pipes?: PipeDefListOrFactory | null,
|
directives?: DirectiveDefListOrFactory | null, pipes?: PipeDefListOrFactory | null,
|
||||||
sanitizer?: Sanitizer | null): LView {
|
sanitizer?: Sanitizer | null): LView {
|
||||||
if (hostView == null) {
|
if (componentView === null) {
|
||||||
resetComponentState();
|
resetComponentState();
|
||||||
const renderer = providedRendererFactory.createRenderer(null, null);
|
const renderer = providedRendererFactory.createRenderer(null, null);
|
||||||
|
|
||||||
// We need to create a root view so it's possible to look up the host element through its index
|
// We need to create a root view so it's possible to look up the host element through its index
|
||||||
const hostLView = createLView(
|
const hostLView = createLView(
|
||||||
null, createTView(-1, null, 1, 0, null, null, null), {},
|
null, createTView(-1, null, 1, 0, null, null, null), {},
|
||||||
LViewFlags.CheckAlways | LViewFlags.IsRoot, providedRendererFactory, renderer);
|
LViewFlags.CheckAlways | LViewFlags.IsRoot, null, null, providedRendererFactory, renderer);
|
||||||
enterView(hostLView, null); // SUSPECT! why do we need to enter the View?
|
enterView(hostLView, null); // SUSPECT! why do we need to enter the View?
|
||||||
|
|
||||||
const componentTView =
|
const componentTView =
|
||||||
getOrCreateTView(templateFn, consts, vars, directives || null, pipes || null, null);
|
getOrCreateTView(templateFn, consts, vars, directives || null, pipes || null, null);
|
||||||
hostView = createLView(
|
const hostTNode = createNodeAtIndex(0, TNodeType.Element, hostNode, null, null);
|
||||||
hostLView, componentTView, context, LViewFlags.CheckAlways, providedRendererFactory,
|
componentView = createLView(
|
||||||
renderer, sanitizer);
|
hostLView, componentTView, context, LViewFlags.CheckAlways, hostNode, hostTNode,
|
||||||
hostView[HOST_NODE] = createNodeAtIndex(0, TNodeType.Element, hostNode, null, null);
|
providedRendererFactory, renderer, sanitizer);
|
||||||
}
|
}
|
||||||
renderComponentOrTemplate(hostView, context, templateFn);
|
renderComponentOrTemplate(componentView, context, templateFn);
|
||||||
return hostView;
|
return componentView;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -343,7 +346,7 @@ export function createEmbeddedViewAndNode<T>(
|
||||||
setIsParent(true);
|
setIsParent(true);
|
||||||
setPreviousOrParentTNode(null !);
|
setPreviousOrParentTNode(null !);
|
||||||
|
|
||||||
const lView = createLView(declarationView, tView, context, LViewFlags.CheckAlways);
|
const lView = createLView(declarationView, tView, context, LViewFlags.CheckAlways, null, null);
|
||||||
lView[DECLARATION_VIEW] = declarationView;
|
lView[DECLARATION_VIEW] = declarationView;
|
||||||
|
|
||||||
if (queries) {
|
if (queries) {
|
||||||
|
@ -382,7 +385,7 @@ export function renderEmbeddedTemplate<T>(viewToRender: LView, tView: TView, con
|
||||||
setIsParent(true);
|
setIsParent(true);
|
||||||
setPreviousOrParentTNode(null !);
|
setPreviousOrParentTNode(null !);
|
||||||
|
|
||||||
oldView = enterView(viewToRender, viewToRender[HOST_NODE]);
|
oldView = enterView(viewToRender, viewToRender[T_HOST]);
|
||||||
namespaceHTML();
|
namespaceHTML();
|
||||||
tView.template !(getRenderFlags(viewToRender), context);
|
tView.template !(getRenderFlags(viewToRender), context);
|
||||||
// This must be set to false immediately after the first creation run because in an
|
// This must be set to false immediately after the first creation run because in an
|
||||||
|
@ -417,7 +420,7 @@ export function nextContext<T = any>(level: number = 1): T {
|
||||||
function renderComponentOrTemplate<T>(
|
function renderComponentOrTemplate<T>(
|
||||||
hostView: LView, context: T, templateFn?: ComponentTemplate<T>) {
|
hostView: LView, context: T, templateFn?: ComponentTemplate<T>) {
|
||||||
const rendererFactory = hostView[RENDERER_FACTORY];
|
const rendererFactory = hostView[RENDERER_FACTORY];
|
||||||
const oldView = enterView(hostView, hostView[HOST_NODE]);
|
const oldView = enterView(hostView, hostView[T_HOST]);
|
||||||
const normalExecutionPath = !getCheckNoChangesMode();
|
const normalExecutionPath = !getCheckNoChangesMode();
|
||||||
const creationModeIsActive = isCreationMode(hostView);
|
const creationModeIsActive = isCreationMode(hostView);
|
||||||
try {
|
try {
|
||||||
|
@ -1962,13 +1965,13 @@ function addComponentLogic<T>(
|
||||||
lView, previousOrParentTNode.index as number,
|
lView, previousOrParentTNode.index as number,
|
||||||
createLView(
|
createLView(
|
||||||
lView, tView, null, def.onPush ? LViewFlags.Dirty : LViewFlags.CheckAlways,
|
lView, tView, null, def.onPush ? LViewFlags.Dirty : LViewFlags.CheckAlways,
|
||||||
|
lView[previousOrParentTNode.index], previousOrParentTNode as TElementNode,
|
||||||
rendererFactory, lView[RENDERER_FACTORY].createRenderer(native as RElement, def)));
|
rendererFactory, lView[RENDERER_FACTORY].createRenderer(native as RElement, def)));
|
||||||
|
|
||||||
componentView[HOST_NODE] = previousOrParentTNode as TElementNode;
|
componentView[T_HOST] = previousOrParentTNode as TElementNode;
|
||||||
|
|
||||||
// Component view will always be created before any injected LContainers,
|
// Component view will always be created before any injected LContainers,
|
||||||
// so this is a regular element, wrap it with the component view
|
// so this is a regular element, wrap it with the component view
|
||||||
componentView[HOST] = lView[previousOrParentTNode.index];
|
|
||||||
lView[previousOrParentTNode.index] = componentView;
|
lView[previousOrParentTNode.index] = componentView;
|
||||||
|
|
||||||
if (lView[TVIEW].firstTemplatePass) {
|
if (lView[TVIEW].firstTemplatePass) {
|
||||||
|
@ -2308,7 +2311,7 @@ export function embeddedViewStart(viewBlockId: number, consts: number, vars: num
|
||||||
viewToRender = createLView(
|
viewToRender = createLView(
|
||||||
lView,
|
lView,
|
||||||
getOrCreateEmbeddedTView(viewBlockId, consts, vars, containerTNode as TContainerNode), null,
|
getOrCreateEmbeddedTView(viewBlockId, consts, vars, containerTNode as TContainerNode), null,
|
||||||
LViewFlags.CheckAlways);
|
LViewFlags.CheckAlways, null, null);
|
||||||
|
|
||||||
if (lContainer[QUERIES]) {
|
if (lContainer[QUERIES]) {
|
||||||
viewToRender[QUERIES] = lContainer[QUERIES] !.createView();
|
viewToRender[QUERIES] = lContainer[QUERIES] !.createView();
|
||||||
|
@ -2360,7 +2363,7 @@ function getOrCreateEmbeddedTView(
|
||||||
/** Marks the end of an embedded view. */
|
/** Marks the end of an embedded view. */
|
||||||
export function embeddedViewEnd(): void {
|
export function embeddedViewEnd(): void {
|
||||||
const lView = getLView();
|
const lView = getLView();
|
||||||
const viewHost = lView[HOST_NODE];
|
const viewHost = lView[T_HOST];
|
||||||
|
|
||||||
if (isCreationMode(lView)) {
|
if (isCreationMode(lView)) {
|
||||||
refreshDescendantViews(lView); // creation mode pass
|
refreshDescendantViews(lView); // creation mode pass
|
||||||
|
@ -2452,7 +2455,7 @@ export function viewAttached(view: LView): boolean {
|
||||||
* @param rawSelectors A collection of CSS selectors in the raw, un-parsed form
|
* @param rawSelectors A collection of CSS selectors in the raw, un-parsed form
|
||||||
*/
|
*/
|
||||||
export function projectionDef(selectors?: CssSelectorList[], textSelectors?: string[]): void {
|
export function projectionDef(selectors?: CssSelectorList[], textSelectors?: string[]): void {
|
||||||
const componentNode = findComponentView(getLView())[HOST_NODE] as TElementNode;
|
const componentNode = findComponentView(getLView())[T_HOST] as TElementNode;
|
||||||
|
|
||||||
if (!componentNode.projection) {
|
if (!componentNode.projection) {
|
||||||
const noOfNodeBuckets = selectors ? selectors.length + 1 : 1;
|
const noOfNodeBuckets = selectors ? selectors.length + 1 : 1;
|
||||||
|
@ -2511,7 +2514,7 @@ export function projection(nodeIndex: number, selectorIndex: number = 0, attrs?:
|
||||||
|
|
||||||
// re-distribution of projectable nodes is stored on a component's view level
|
// re-distribution of projectable nodes is stored on a component's view level
|
||||||
const componentView = findComponentView(lView);
|
const componentView = findComponentView(lView);
|
||||||
const componentNode = componentView[HOST_NODE] as TElementNode;
|
const componentNode = componentView[T_HOST] as TElementNode;
|
||||||
let nodeToProject = (componentNode.projection as(TNode | null)[])[selectorIndex];
|
let nodeToProject = (componentNode.projection as(TNode | null)[])[selectorIndex];
|
||||||
let projectedView = componentView[PARENT] !;
|
let projectedView = componentView[PARENT] !;
|
||||||
let projectionNodeIndex = -1;
|
let projectionNodeIndex = -1;
|
||||||
|
@ -2523,7 +2526,7 @@ export function projection(nodeIndex: number, selectorIndex: number = 0, attrs?:
|
||||||
if (nodeToProject.type === TNodeType.Projection) {
|
if (nodeToProject.type === TNodeType.Projection) {
|
||||||
// This node is re-projected, so we must go up the tree to get its projected nodes.
|
// This node is re-projected, so we must go up the tree to get its projected nodes.
|
||||||
const currentComponentView = findComponentView(projectedView);
|
const currentComponentView = findComponentView(projectedView);
|
||||||
const currentComponentHost = currentComponentView[HOST_NODE] as TElementNode;
|
const currentComponentHost = currentComponentView[T_HOST] as TElementNode;
|
||||||
const firstProjectedNode = (currentComponentHost.projection as(
|
const firstProjectedNode = (currentComponentHost.projection as(
|
||||||
TNode | null)[])[nodeToProject.projection as number];
|
TNode | null)[])[nodeToProject.projection as number];
|
||||||
|
|
||||||
|
@ -2799,7 +2802,7 @@ export function checkNoChangesInRootView(lView: LView): void {
|
||||||
/** Checks the view of the component provided. Does not gate on dirty checks or execute doCheck. */
|
/** Checks the view of the component provided. Does not gate on dirty checks or execute doCheck. */
|
||||||
export function checkView<T>(hostView: LView, component: T) {
|
export function checkView<T>(hostView: LView, component: T) {
|
||||||
const hostTView = hostView[TVIEW];
|
const hostTView = hostView[TVIEW];
|
||||||
const oldView = enterView(hostView, hostView[HOST_NODE]);
|
const oldView = enterView(hostView, hostView[T_HOST]);
|
||||||
const templateFn = hostTView.template !;
|
const templateFn = hostTView.template !;
|
||||||
const creationMode = isCreationMode(hostView);
|
const creationMode = isCreationMode(hostView);
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ export const PARENT = 2;
|
||||||
export const NEXT = 3;
|
export const NEXT = 3;
|
||||||
export const QUERIES = 4;
|
export const QUERIES = 4;
|
||||||
export const HOST = 5;
|
export const HOST = 5;
|
||||||
export const HOST_NODE = 6; // Rename to `T_HOST`?
|
export const T_HOST = 6;
|
||||||
export const BINDING_INDEX = 7;
|
export const BINDING_INDEX = 7;
|
||||||
export const CLEANUP = 8;
|
export const CLEANUP = 8;
|
||||||
export const CONTEXT = 9;
|
export const CONTEXT = 9;
|
||||||
|
@ -118,7 +118,7 @@ export interface LView extends Array<any> {
|
||||||
*
|
*
|
||||||
* If null, this is the root view of an application (root component is in this view).
|
* If null, this is the root view of an application (root component is in this view).
|
||||||
*/
|
*/
|
||||||
[HOST_NODE]: TViewNode|TElementNode|null;
|
[T_HOST]: TViewNode|TElementNode|null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The binding index we should access next.
|
* The binding index we should access next.
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {ViewEncapsulation} from '../metadata/view';
|
import {ViewEncapsulation} from '../metadata/view';
|
||||||
|
|
||||||
import {attachPatchData} from './context_discovery';
|
import {attachPatchData} from './context_discovery';
|
||||||
import {callHooks} from './hooks';
|
import {callHooks} from './hooks';
|
||||||
import {LContainer, NATIVE, VIEWS, unusedValueExportToPlacateAjd as unused1} from './interfaces/container';
|
import {LContainer, NATIVE, VIEWS, unusedValueExportToPlacateAjd as unused1} from './interfaces/container';
|
||||||
|
@ -14,7 +15,7 @@ import {ComponentDef} from './interfaces/definition';
|
||||||
import {TContainerNode, TElementContainerNode, TElementNode, TNode, TNodeFlags, TNodeType, TViewNode, unusedValueExportToPlacateAjd as unused2} from './interfaces/node';
|
import {TContainerNode, TElementContainerNode, TElementNode, TNode, TNodeFlags, TNodeType, TViewNode, unusedValueExportToPlacateAjd as unused2} from './interfaces/node';
|
||||||
import {unusedValueExportToPlacateAjd as unused3} from './interfaces/projection';
|
import {unusedValueExportToPlacateAjd as unused3} from './interfaces/projection';
|
||||||
import {ProceduralRenderer3, RComment, RElement, RNode, RText, Renderer3, isProceduralRenderer, unusedValueExportToPlacateAjd as unused4} from './interfaces/renderer';
|
import {ProceduralRenderer3, RComment, RElement, RNode, RText, Renderer3, isProceduralRenderer, unusedValueExportToPlacateAjd as unused4} from './interfaces/renderer';
|
||||||
import {CLEANUP, CONTAINER_INDEX, FLAGS, HEADER_OFFSET, HOST_NODE, HookData, LView, LViewFlags, NEXT, PARENT, QUERIES, RENDERER, TVIEW, unusedValueExportToPlacateAjd as unused5} from './interfaces/view';
|
import {CLEANUP, CONTAINER_INDEX, FLAGS, HEADER_OFFSET, HookData, LView, LViewFlags, NEXT, PARENT, QUERIES, RENDERER, TVIEW, T_HOST, unusedValueExportToPlacateAjd as unused5} from './interfaces/view';
|
||||||
import {assertNodeType} from './node_assert';
|
import {assertNodeType} from './node_assert';
|
||||||
import {findComponentView, getNativeByTNode, isComponent, isLContainer, isRootView, readElementValue, renderStringify} from './util';
|
import {findComponentView, getNativeByTNode, isComponent, isLContainer, isRootView, readElementValue, renderStringify} from './util';
|
||||||
|
|
||||||
|
@ -107,7 +108,7 @@ function walkTNodeTree(
|
||||||
}
|
}
|
||||||
} else if (tNode.type === TNodeType.Projection) {
|
} else if (tNode.type === TNodeType.Projection) {
|
||||||
const componentView = findComponentView(currentView !);
|
const componentView = findComponentView(currentView !);
|
||||||
const componentHost = componentView[HOST_NODE] as TElementNode;
|
const componentHost = componentView[T_HOST] as TElementNode;
|
||||||
const head: TNode|null =
|
const head: TNode|null =
|
||||||
(componentHost.projection as(TNode | null)[])[tNode.projection as number];
|
(componentHost.projection as(TNode | null)[])[tNode.projection as number];
|
||||||
|
|
||||||
|
@ -398,7 +399,7 @@ export function destroyLView(view: LView) {
|
||||||
*/
|
*/
|
||||||
export function getParentState(state: LView | LContainer, rootView: LView): LView|LContainer|null {
|
export function getParentState(state: LView | LContainer, rootView: LView): LView|LContainer|null {
|
||||||
let tNode;
|
let tNode;
|
||||||
if (state.length >= HEADER_OFFSET && (tNode = (state as LView) ![HOST_NODE]) &&
|
if (state.length >= HEADER_OFFSET && (tNode = (state as LView) ![T_HOST]) &&
|
||||||
tNode.type === TNodeType.View) {
|
tNode.type === TNodeType.View) {
|
||||||
// if it's an embedded view, the state needs to go up to the container, in case the
|
// if it's an embedded view, the state needs to go up to the container, in case the
|
||||||
// container has a next
|
// container has a next
|
||||||
|
@ -429,7 +430,7 @@ function cleanUpView(viewOrContainer: LView | LContainer): void {
|
||||||
|
|
||||||
executeOnDestroys(view);
|
executeOnDestroys(view);
|
||||||
removeListeners(view);
|
removeListeners(view);
|
||||||
const hostTNode = view[HOST_NODE];
|
const hostTNode = view[T_HOST];
|
||||||
// For component views only, the local renderer is destroyed as clean up time.
|
// For component views only, the local renderer is destroyed as clean up time.
|
||||||
if (hostTNode && hostTNode.type === TNodeType.Element && isProceduralRenderer(view[RENDERER])) {
|
if (hostTNode && hostTNode.type === TNodeType.Element && isProceduralRenderer(view[RENDERER])) {
|
||||||
ngDevMode && ngDevMode.rendererDestroy++;
|
ngDevMode && ngDevMode.rendererDestroy++;
|
||||||
|
@ -513,7 +514,7 @@ function getRenderParent(tNode: TNode, currentView: LView): RElement|null {
|
||||||
// If the parent is null, then we are inserting across views: either into an embedded view or a
|
// If the parent is null, then we are inserting across views: either into an embedded view or a
|
||||||
// component view.
|
// component view.
|
||||||
if (parent == null) {
|
if (parent == null) {
|
||||||
const hostTNode = currentView[HOST_NODE] !;
|
const hostTNode = currentView[T_HOST] !;
|
||||||
if (hostTNode.type === TNodeType.View) {
|
if (hostTNode.type === TNodeType.View) {
|
||||||
// We are inserting a root element of an embedded view We might delay insertion of children
|
// We are inserting a root element of an embedded view We might delay insertion of children
|
||||||
// for a given view if it is disconnected. This might happen for 2 main reasons:
|
// for a given view if it is disconnected. This might happen for 2 main reasons:
|
||||||
|
@ -556,7 +557,7 @@ function getRenderParent(tNode: TNode, currentView: LView): RElement|null {
|
||||||
* a host element.
|
* a host element.
|
||||||
*/
|
*/
|
||||||
function getHostNative(currentView: LView): RElement|null {
|
function getHostNative(currentView: LView): RElement|null {
|
||||||
const hostTNode = currentView[HOST_NODE];
|
const hostTNode = currentView[T_HOST];
|
||||||
return hostTNode && hostTNode.type === TNodeType.Element ?
|
return hostTNode && hostTNode.type === TNodeType.Element ?
|
||||||
(getNativeByTNode(hostTNode, currentView[PARENT] !) as RElement) :
|
(getNativeByTNode(hostTNode, currentView[PARENT] !) as RElement) :
|
||||||
null;
|
null;
|
||||||
|
@ -651,7 +652,7 @@ export function appendChild(childEl: RNode | RNode[], childTNode: TNode, current
|
||||||
const renderParent = getRenderParent(childTNode, currentView);
|
const renderParent = getRenderParent(childTNode, currentView);
|
||||||
if (renderParent != null) {
|
if (renderParent != null) {
|
||||||
const renderer = currentView[RENDERER];
|
const renderer = currentView[RENDERER];
|
||||||
const parentTNode: TNode = childTNode.parent || currentView[HOST_NODE] !;
|
const parentTNode: TNode = childTNode.parent || currentView[T_HOST] !;
|
||||||
const anchorNode = getNativeAnchorNode(parentTNode, currentView);
|
const anchorNode = getNativeAnchorNode(parentTNode, currentView);
|
||||||
if (Array.isArray(childEl)) {
|
if (Array.isArray(childEl)) {
|
||||||
for (let nativeNode of childEl) {
|
for (let nativeNode of childEl) {
|
||||||
|
@ -680,7 +681,7 @@ function getHighestElementOrICUContainer(tNode: TNode): TNode {
|
||||||
export function getBeforeNodeForView(index: number, views: LView[], containerNative: RComment) {
|
export function getBeforeNodeForView(index: number, views: LView[], containerNative: RComment) {
|
||||||
if (index + 1 < views.length) {
|
if (index + 1 < views.length) {
|
||||||
const view = views[index + 1] as LView;
|
const view = views[index + 1] as LView;
|
||||||
const viewTNode = view[HOST_NODE] as TViewNode;
|
const viewTNode = view[T_HOST] as TViewNode;
|
||||||
return viewTNode.child ? getNativeByTNode(viewTNode.child, view) : containerNative;
|
return viewTNode.child ? getNativeByTNode(viewTNode.child, view) : containerNative;
|
||||||
} else {
|
} else {
|
||||||
return containerNative;
|
return containerNative;
|
||||||
|
|
|
@ -7,11 +7,12 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {assertDefined} from '../util/assert';
|
import {assertDefined} from '../util/assert';
|
||||||
|
|
||||||
import {executeHooks} from './hooks';
|
import {executeHooks} from './hooks';
|
||||||
import {ComponentDef, DirectiveDef} from './interfaces/definition';
|
import {ComponentDef, DirectiveDef} from './interfaces/definition';
|
||||||
import {TElementNode, TNode, TNodeFlags, TViewNode} from './interfaces/node';
|
import {TElementNode, TNode, TNodeFlags, TViewNode} from './interfaces/node';
|
||||||
import {LQueries} from './interfaces/query';
|
import {LQueries} from './interfaces/query';
|
||||||
import {BINDING_INDEX, CONTEXT, DECLARATION_VIEW, FLAGS, HOST_NODE, InitPhaseState, LView, LViewFlags, OpaqueViewState, QUERIES, TVIEW} from './interfaces/view';
|
import {BINDING_INDEX, CONTEXT, DECLARATION_VIEW, FLAGS, InitPhaseState, LView, LViewFlags, OpaqueViewState, QUERIES, TVIEW, T_HOST} from './interfaces/view';
|
||||||
import {isContentQueryHost} from './util';
|
import {isContentQueryHost} from './util';
|
||||||
|
|
||||||
|
|
||||||
|
@ -178,7 +179,7 @@ export function getOrCreateCurrentQueries(
|
||||||
// If this is the first content query on a node, any existing LQueries needs to be cloned.
|
// If this is the first content query on a node, any existing LQueries needs to be cloned.
|
||||||
// In subsequent template passes, the cloning occurs before directive instantiation
|
// In subsequent template passes, the cloning occurs before directive instantiation
|
||||||
// in `createDirectivesAndLocals`.
|
// in `createDirectivesAndLocals`.
|
||||||
if (previousOrParentTNode && previousOrParentTNode !== lView[HOST_NODE] &&
|
if (previousOrParentTNode && previousOrParentTNode !== lView[T_HOST] &&
|
||||||
!isContentQueryHost(previousOrParentTNode)) {
|
!isContentQueryHost(previousOrParentTNode)) {
|
||||||
currentQueries && (currentQueries = lView[QUERIES] = currentQueries.clone());
|
currentQueries && (currentQueries = lView[QUERIES] = currentQueries.clone());
|
||||||
previousOrParentTNode.flags |= TNodeFlags.hasContentQuery;
|
previousOrParentTNode.flags |= TNodeFlags.hasContentQuery;
|
||||||
|
|
|
@ -16,7 +16,8 @@ import {NO_PARENT_INJECTOR, RelativeInjectorLocation, RelativeInjectorLocationFl
|
||||||
import {TContainerNode, TElementNode, TNode, TNodeFlags, TNodeType} from './interfaces/node';
|
import {TContainerNode, TElementNode, TNode, TNodeFlags, TNodeType} from './interfaces/node';
|
||||||
import {RComment, RElement, RText} from './interfaces/renderer';
|
import {RComment, RElement, RText} from './interfaces/renderer';
|
||||||
import {StylingContext} from './interfaces/styling';
|
import {StylingContext} from './interfaces/styling';
|
||||||
import {CONTEXT, DECLARATION_VIEW, FLAGS, HEADER_OFFSET, HOST, HOST_NODE, LView, LViewFlags, PARENT, RootContext, TData, TVIEW, TView} from './interfaces/view';
|
import {CONTEXT, DECLARATION_VIEW, FLAGS, HEADER_OFFSET, HOST, LView, LViewFlags, PARENT, RootContext, TData, TVIEW, TView, T_HOST} from './interfaces/view';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -235,12 +236,12 @@ export function getParentInjectorTNode(
|
||||||
let viewOffset = getParentInjectorViewOffset(location);
|
let viewOffset = getParentInjectorViewOffset(location);
|
||||||
// view offset is 1
|
// view offset is 1
|
||||||
let parentView = startView;
|
let parentView = startView;
|
||||||
let parentTNode = startView[HOST_NODE] as TElementNode;
|
let parentTNode = startView[T_HOST] as TElementNode;
|
||||||
|
|
||||||
// view offset is superior to 1
|
// view offset is superior to 1
|
||||||
while (viewOffset > 1) {
|
while (viewOffset > 1) {
|
||||||
parentView = parentView[DECLARATION_VIEW] !;
|
parentView = parentView[DECLARATION_VIEW] !;
|
||||||
parentTNode = parentView[HOST_NODE] as TElementNode;
|
parentTNode = parentView[T_HOST] as TElementNode;
|
||||||
viewOffset--;
|
viewOffset--;
|
||||||
}
|
}
|
||||||
return parentTNode;
|
return parentTNode;
|
||||||
|
@ -270,12 +271,12 @@ export function addAllToArray(items: any[], arr: any[]) {
|
||||||
* @returns The host node
|
* @returns The host node
|
||||||
*/
|
*/
|
||||||
export function findComponentView(lView: LView): LView {
|
export function findComponentView(lView: LView): LView {
|
||||||
let rootTNode = lView[HOST_NODE];
|
let rootTNode = lView[T_HOST];
|
||||||
|
|
||||||
while (rootTNode && rootTNode.type === TNodeType.View) {
|
while (rootTNode && rootTNode.type === TNodeType.View) {
|
||||||
ngDevMode && assertDefined(lView[DECLARATION_VIEW], 'lView[DECLARATION_VIEW]');
|
ngDevMode && assertDefined(lView[DECLARATION_VIEW], 'lView[DECLARATION_VIEW]');
|
||||||
lView = lView[DECLARATION_VIEW] !;
|
lView = lView[DECLARATION_VIEW] !;
|
||||||
rootTNode = lView[HOST_NODE];
|
rootTNode = lView[T_HOST];
|
||||||
}
|
}
|
||||||
|
|
||||||
return lView;
|
return lView;
|
||||||
|
|
|
@ -16,12 +16,13 @@ import {ViewContainerRef as ViewEngine_ViewContainerRef} from '../linker/view_co
|
||||||
import {EmbeddedViewRef as viewEngine_EmbeddedViewRef, ViewRef as viewEngine_ViewRef} from '../linker/view_ref';
|
import {EmbeddedViewRef as viewEngine_EmbeddedViewRef, ViewRef as viewEngine_ViewRef} from '../linker/view_ref';
|
||||||
import {Renderer2} from '../render/api';
|
import {Renderer2} from '../render/api';
|
||||||
import {assertDefined, assertGreaterThan, assertLessThan} from '../util/assert';
|
import {assertDefined, assertGreaterThan, assertLessThan} from '../util/assert';
|
||||||
|
|
||||||
import {NodeInjector, getParentInjectorLocation} from './di';
|
import {NodeInjector, getParentInjectorLocation} from './di';
|
||||||
import {addToViewTree, createEmbeddedViewAndNode, createLContainer, renderEmbeddedTemplate} from './instructions';
|
import {addToViewTree, createEmbeddedViewAndNode, createLContainer, renderEmbeddedTemplate} from './instructions';
|
||||||
import {ACTIVE_INDEX, LContainer, NATIVE, VIEWS} from './interfaces/container';
|
import {ACTIVE_INDEX, LContainer, NATIVE, VIEWS} from './interfaces/container';
|
||||||
import {TContainerNode, TElementContainerNode, TElementNode, TNode, TNodeType, TViewNode} from './interfaces/node';
|
import {TContainerNode, TElementContainerNode, TElementNode, TNode, TNodeType, TViewNode} from './interfaces/node';
|
||||||
import {RComment, RElement, Renderer3, isProceduralRenderer} from './interfaces/renderer';
|
import {RComment, RElement, Renderer3, isProceduralRenderer} from './interfaces/renderer';
|
||||||
import {CONTAINER_INDEX, CONTEXT, HOST_NODE, LView, QUERIES, RENDERER, TView} from './interfaces/view';
|
import {CONTAINER_INDEX, CONTEXT, LView, QUERIES, RENDERER, TView, T_HOST} from './interfaces/view';
|
||||||
import {assertNodeOfPossibleTypes} from './node_assert';
|
import {assertNodeOfPossibleTypes} from './node_assert';
|
||||||
import {addRemoveViewFromContainer, appendChild, detachView, getBeforeNodeForView, insertView, nativeInsertBefore, nativeNextSibling, nativeParentNode, removeView} from './node_manipulation';
|
import {addRemoveViewFromContainer, appendChild, detachView, getBeforeNodeForView, insertView, nativeInsertBefore, nativeNextSibling, nativeParentNode, removeView} from './node_manipulation';
|
||||||
import {getLView, getPreviousOrParentTNode} from './state';
|
import {getLView, getPreviousOrParentTNode} from './state';
|
||||||
|
@ -29,6 +30,7 @@ import {findComponentView, getComponentViewByIndex, getNativeByTNode, getParentI
|
||||||
import {ViewRef} from './view_ref';
|
import {ViewRef} from './view_ref';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an ElementRef from the most recent node.
|
* Creates an ElementRef from the most recent node.
|
||||||
*
|
*
|
||||||
|
@ -112,7 +114,7 @@ export function createTemplateRef<T>(
|
||||||
}
|
}
|
||||||
renderEmbeddedTemplate(lView, this._tView, context);
|
renderEmbeddedTemplate(lView, this._tView, context);
|
||||||
const viewRef = new ViewRef(lView, context, -1);
|
const viewRef = new ViewRef(lView, context, -1);
|
||||||
viewRef._tViewNode = lView[HOST_NODE] as TViewNode;
|
viewRef._tViewNode = lView[T_HOST] as TViewNode;
|
||||||
return viewRef;
|
return viewRef;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -13,7 +13,7 @@ import {EmbeddedViewRef as viewEngine_EmbeddedViewRef, InternalViewRef as viewEn
|
||||||
|
|
||||||
import {checkNoChanges, checkNoChangesInRootView, checkView, detectChangesInRootView, detectChangesInternal, markViewDirty, storeCleanupFn, viewAttached} from './instructions';
|
import {checkNoChanges, checkNoChangesInRootView, checkView, detectChangesInRootView, detectChangesInternal, markViewDirty, storeCleanupFn, viewAttached} from './instructions';
|
||||||
import {TNode, TNodeType, TViewNode} from './interfaces/node';
|
import {TNode, TNodeType, TViewNode} from './interfaces/node';
|
||||||
import {FLAGS, HOST, HOST_NODE, LView, LViewFlags, PARENT, RENDERER_FACTORY} from './interfaces/view';
|
import {FLAGS, HOST, LView, LViewFlags, PARENT, RENDERER_FACTORY, T_HOST} from './interfaces/view';
|
||||||
import {destroyLView} from './node_manipulation';
|
import {destroyLView} from './node_manipulation';
|
||||||
import {getNativeByTNode} from './util';
|
import {getNativeByTNode} from './util';
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ export class ViewRef<T> implements viewEngine_EmbeddedViewRef<T>, viewEngine_Int
|
||||||
|
|
||||||
get rootNodes(): any[] {
|
get rootNodes(): any[] {
|
||||||
if (this._lView[HOST] == null) {
|
if (this._lView[HOST] == null) {
|
||||||
const tView = this._lView[HOST_NODE] as TViewNode;
|
const tView = this._lView[T_HOST] as TViewNode;
|
||||||
return collectNativeNodes(this._lView, tView, []);
|
return collectNativeNodes(this._lView, tView, []);
|
||||||
}
|
}
|
||||||
return [];
|
return [];
|
||||||
|
|
|
@ -51,7 +51,7 @@
|
||||||
"name": "HOST"
|
"name": "HOST"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "HOST_NODE"
|
"name": "T_HOST"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "INJECTOR"
|
"name": "INJECTOR"
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
"name": "HOST"
|
"name": "HOST"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "HOST_NODE"
|
"name": "T_HOST"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "INJECTOR"
|
"name": "INJECTOR"
|
||||||
|
|
|
@ -81,7 +81,7 @@
|
||||||
"name": "HOST"
|
"name": "HOST"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "HOST_NODE"
|
"name": "T_HOST"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "INJECTOR"
|
"name": "INJECTOR"
|
||||||
|
|
|
@ -2320,8 +2320,8 @@ describe('di', () => {
|
||||||
describe('getOrCreateNodeInjector', () => {
|
describe('getOrCreateNodeInjector', () => {
|
||||||
it('should handle initial undefined state', () => {
|
it('should handle initial undefined state', () => {
|
||||||
const contentView = createLView(
|
const contentView = createLView(
|
||||||
null, createTView(-1, null, 1, 0, null, null, null), null, LViewFlags.CheckAlways,
|
null, createTView(-1, null, 1, 0, null, null, null), null, LViewFlags.CheckAlways, null,
|
||||||
{} as any, {} as any);
|
null, {} as any, {} as any);
|
||||||
const oldView = enterView(contentView, null);
|
const oldView = enterView(contentView, null);
|
||||||
try {
|
try {
|
||||||
const parentTNode = createNodeAtIndex(0, TNodeType.Element, null, null, null);
|
const parentTNode = createNodeAtIndex(0, TNodeType.Element, null, null, null);
|
||||||
|
|
|
@ -34,8 +34,8 @@ describe('style and class based bindings', () => {
|
||||||
const rootContext =
|
const rootContext =
|
||||||
createRootContext(requestAnimationFrame.bind(window), playerHandler || null);
|
createRootContext(requestAnimationFrame.bind(window), playerHandler || null);
|
||||||
const lView = createLView(
|
const lView = createLView(
|
||||||
null, createTView(-1, null, 1, 0, null, null, null), rootContext, LViewFlags.IsRoot,
|
null, createTView(-1, null, 1, 0, null, null, null), rootContext, LViewFlags.IsRoot, null,
|
||||||
domRendererFactory3, domRendererFactory3.createRenderer(element, null));
|
null, domRendererFactory3, domRendererFactory3.createRenderer(element, null));
|
||||||
return lView;
|
return lView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue