refactor(core): Rename `TView.node` to `TView.declTNode`. (#38707)

The value stored in `TView.node` is really the declaration `TNode`,
therefore renaming to make it more explicit.

PR Close #38707
This commit is contained in:
Misko Hevery 2020-09-14 13:14:12 -07:00 committed by Alex Rickabaugh
parent 5db84d7221
commit 5a86fb33ba
6 changed files with 11 additions and 11 deletions

View File

@ -203,7 +203,8 @@ export function getInjectorIndex(tNode: TNode, lView: LView): number {
* Finds the index of the parent injector, with a view offset if applicable. Used to set the
* parent injector initially.
*
* Returns a combination of number of `LView` we have to go up and index in that `LView`
* @returns Returns a number that is the combination of the number of LViews that we have to go up
* to find the LView containing the parent inject AND the index of the injector within that LView.
*/
export function getParentInjectorLocation(tNode: TNode, lView: LView): RelativeInjectorLocation {
if (tNode.parent && tNode.parent.injectorIndex !== -1) {
@ -227,8 +228,9 @@ export function getParentInjectorLocation(tNode: TNode, lView: LView): RelativeI
const tView = lViewCursor[TVIEW];
const tViewType = tView.type;
if (tViewType === TViewType.Embedded) {
ngDevMode && assertDefined(tView.node, 'Embedded TNodes should have declaration parents.');
parentTNode = tView.node;
ngDevMode &&
assertDefined(tView.declTNode, 'Embedded TNodes should have declaration parents.');
parentTNode = tView.declTNode;
} else if (tViewType === TViewType.Component) {
// Components don't have `TView.declTNode` because each instance of component could be
// inserted in different location, hence `TView.declTNode` is meaningless.
@ -255,7 +257,6 @@ export function getParentInjectorLocation(tNode: TNode, lView: LView): RelativeI
}
return NO_PARENT_INJECTOR;
}
/**
* Makes a type or an injection token public to the DI system by adding it to an
* injector's bloom filter.

View File

@ -120,7 +120,7 @@ export const TViewConstructor = class TView implements ITView {
public template: ComponentTemplate<{}>|null, //
public queries: TQueries|null, //
public viewQuery: ViewQueriesFunction<{}>|null, //
public node: ITNode|null, //
public declTNode: ITNode|null, //
public data: TData, //
public bindingStartIndex: number, //
public expandoStartIndex: number, //

View File

@ -179,7 +179,7 @@ export function createLView<T>(
lView[HOST] = host;
lView[FLAGS] = flags | LViewFlags.CreationMode | LViewFlags.Attached | LViewFlags.FirstLViewPass;
resetPreOrderHookFlags(lView);
ngDevMode && tView.node && parentLView && assertTNodeForLView(tView.node, parentLView);
ngDevMode && tView.declTNode && parentLView && assertTNodeForLView(tView.declTNode, parentLView);
lView[PARENT] = lView[DECLARATION_VIEW] = parentLView;
lView[CONTEXT] = context;
lView[RENDERER_FACTORY] = (rendererFactory || parentLView && parentLView[RENDERER_FACTORY])!;
@ -682,7 +682,7 @@ export function createTView(
template: templateFn,
queries: null,
viewQuery: viewQuery,
node: declTNode,
declTNode: declTNode,
data: blueprint.slice().fill(null, bindingStartIndex),
bindingStartIndex: bindingStartIndex,
expandoStartIndex: initialViewLength,

View File

@ -499,8 +499,7 @@ export interface TView {
/**
* A `TNode` representing the declaration location of this `TView` (not part of this TView).
*/
// FIXME(misko): Rename `node` to `declTNode`
node: TNode|null;
declTNode: TNode|null;
// FIXME(misko): Why does `TView` not have `declarationTView` property?

View File

@ -106,7 +106,7 @@ export function createTemplateRef<T>(
const embeddedTView = this._declarationTContainer.tViews as TView;
const embeddedLView = createLView(
this._declarationView, embeddedTView, context, LViewFlags.CheckAlways, null,
embeddedTView.node, null, null, null, null);
embeddedTView.declTNode, null, null, null, null);
const declarationLContainer = this._declarationView[this._declarationTContainer.index];
ngDevMode && assertLContainer(declarationLContainer);

View File

@ -94,7 +94,7 @@ const ShapeOfTView: ShapeOf<TView> = {
blueprint: true,
template: true,
viewQuery: true,
node: true,
declTNode: true,
firstCreatePass: true,
firstUpdatePass: true,
data: true,