refactor(ivy): rename `getComponentViewByIndex` to `getComponentLViewByIndex` (#33074)
PR Close #33074
This commit is contained in:
parent
7f7dc7c294
commit
f1ffd57105
|
@ -18,7 +18,7 @@ import {getComponent, getContext, getInjectionTokens, getInjector, getListeners,
|
||||||
import {INTERPOLATION_DELIMITER, renderStringify} from '../render3/util/misc_utils';
|
import {INTERPOLATION_DELIMITER, renderStringify} from '../render3/util/misc_utils';
|
||||||
import {isStylingContext, stylingMapToStringMap} from '../render3/util/styling_utils';
|
import {isStylingContext, stylingMapToStringMap} from '../render3/util/styling_utils';
|
||||||
import {findComponentView} from '../render3/util/view_traversal_utils';
|
import {findComponentView} from '../render3/util/view_traversal_utils';
|
||||||
import {getComponentViewByIndex, getNativeByTNodeOrNull} from '../render3/util/view_utils';
|
import {getComponentLViewByIndex, getNativeByTNodeOrNull} from '../render3/util/view_utils';
|
||||||
import {assertDomNode} from '../util/assert';
|
import {assertDomNode} from '../util/assert';
|
||||||
import {DebugContext} from '../view/index';
|
import {DebugContext} from '../view/index';
|
||||||
import {createProxy} from './proxy';
|
import {createProxy} from './proxy';
|
||||||
|
@ -494,7 +494,7 @@ function _queryNodeChildrenR3(
|
||||||
if (isComponentHost(tNode)) {
|
if (isComponentHost(tNode)) {
|
||||||
// If the element is the host of a component, then all nodes in its view have to be processed.
|
// If the element is the host of a component, then all nodes in its view have to be processed.
|
||||||
// Note: the component's content (tNode.child) will be processed from the insertion points.
|
// Note: the component's content (tNode.child) will be processed from the insertion points.
|
||||||
const componentView = getComponentViewByIndex(tNode.index, lView);
|
const componentView = getComponentLViewByIndex(tNode.index, lView);
|
||||||
if (componentView && componentView[TVIEW].firstChild) {
|
if (componentView && componentView[TVIEW].firstChild) {
|
||||||
_queryNodeChildrenR3(
|
_queryNodeChildrenR3(
|
||||||
componentView[TVIEW].firstChild !, componentView, predicate, matches, elementsOnly,
|
componentView[TVIEW].firstChild !, componentView, predicate, matches, elementsOnly,
|
||||||
|
|
|
@ -14,7 +14,7 @@ import {LContext, MONKEY_PATCH_KEY_NAME} from './interfaces/context';
|
||||||
import {TNode, TNodeFlags} from './interfaces/node';
|
import {TNode, TNodeFlags} from './interfaces/node';
|
||||||
import {RElement, RNode} from './interfaces/renderer';
|
import {RElement, RNode} from './interfaces/renderer';
|
||||||
import {CONTEXT, HEADER_OFFSET, HOST, LView, TVIEW} from './interfaces/view';
|
import {CONTEXT, HEADER_OFFSET, HOST, LView, TVIEW} from './interfaces/view';
|
||||||
import {getComponentViewByIndex, getNativeByTNodeOrNull, readPatchedData, unwrapRNode} from './util/view_utils';
|
import {getComponentLViewByIndex, getNativeByTNodeOrNull, readPatchedData, unwrapRNode} from './util/view_utils';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -157,14 +157,14 @@ export function getComponentViewByInstance(componentInstance: {}): LView {
|
||||||
|
|
||||||
if (Array.isArray(lView)) {
|
if (Array.isArray(lView)) {
|
||||||
const nodeIndex = findViaComponent(lView, componentInstance);
|
const nodeIndex = findViaComponent(lView, componentInstance);
|
||||||
view = getComponentViewByIndex(nodeIndex, lView);
|
view = getComponentLViewByIndex(nodeIndex, lView);
|
||||||
const context = createLContext(lView, nodeIndex, view[HOST] as RElement);
|
const context = createLContext(lView, nodeIndex, view[HOST] as RElement);
|
||||||
context.component = componentInstance;
|
context.component = componentInstance;
|
||||||
attachPatchData(componentInstance, context);
|
attachPatchData(componentInstance, context);
|
||||||
attachPatchData(context.native, context);
|
attachPatchData(context.native, context);
|
||||||
} else {
|
} else {
|
||||||
const context = lView as any as LContext;
|
const context = lView as any as LContext;
|
||||||
view = getComponentViewByIndex(context.nodeIndex, context.lView);
|
view = getComponentLViewByIndex(context.nodeIndex, context.lView);
|
||||||
}
|
}
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
@ -228,13 +228,13 @@ function findViaComponent(lView: LView, componentInstance: {}): number {
|
||||||
if (componentIndices) {
|
if (componentIndices) {
|
||||||
for (let i = 0; i < componentIndices.length; i++) {
|
for (let i = 0; i < componentIndices.length; i++) {
|
||||||
const elementComponentIndex = componentIndices[i];
|
const elementComponentIndex = componentIndices[i];
|
||||||
const componentView = getComponentViewByIndex(elementComponentIndex, lView);
|
const componentView = getComponentLViewByIndex(elementComponentIndex, lView);
|
||||||
if (componentView[CONTEXT] === componentInstance) {
|
if (componentView[CONTEXT] === componentInstance) {
|
||||||
return elementComponentIndex;
|
return elementComponentIndex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const rootComponentView = getComponentViewByIndex(HEADER_OFFSET, lView);
|
const rootComponentView = getComponentLViewByIndex(HEADER_OFFSET, lView);
|
||||||
const rootComponent = rootComponentView[CONTEXT];
|
const rootComponent = rootComponentView[CONTEXT];
|
||||||
if (rootComponent === componentInstance) {
|
if (rootComponent === componentInstance) {
|
||||||
// we are dealing with the root element here therefore we know that the
|
// we are dealing with the root element here therefore we know that the
|
||||||
|
|
|
@ -16,7 +16,7 @@ import {isDirectiveHost} from '../interfaces/type_checks';
|
||||||
import {CLEANUP, FLAGS, LView, LViewFlags, RENDERER, TVIEW} from '../interfaces/view';
|
import {CLEANUP, FLAGS, LView, LViewFlags, RENDERER, TVIEW} from '../interfaces/view';
|
||||||
import {assertNodeOfPossibleTypes} from '../node_assert';
|
import {assertNodeOfPossibleTypes} from '../node_assert';
|
||||||
import {getLView, getPreviousOrParentTNode} from '../state';
|
import {getLView, getPreviousOrParentTNode} from '../state';
|
||||||
import {getComponentViewByIndex, getNativeByTNode, unwrapRNode} from '../util/view_utils';
|
import {getComponentLViewByIndex, getNativeByTNode, unwrapRNode} from '../util/view_utils';
|
||||||
import {getCleanup, handleError, loadComponentRenderer, markViewDirty} from './shared';
|
import {getCleanup, handleError, loadComponentRenderer, markViewDirty} from './shared';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -248,7 +248,7 @@ function wrapListener(
|
||||||
// In order to be backwards compatible with View Engine, events on component host nodes
|
// In order to be backwards compatible with View Engine, events on component host nodes
|
||||||
// must also mark the component view itself dirty (i.e. the view that it owns).
|
// must also mark the component view itself dirty (i.e. the view that it owns).
|
||||||
const startView = tNode.flags & TNodeFlags.isComponentHost ?
|
const startView = tNode.flags & TNodeFlags.isComponentHost ?
|
||||||
getComponentViewByIndex(tNode.index, lView) :
|
getComponentLViewByIndex(tNode.index, lView) :
|
||||||
lView;
|
lView;
|
||||||
|
|
||||||
// See interfaces/view.ts for more on LViewFlags.ManualOnPush
|
// See interfaces/view.ts for more on LViewFlags.ManualOnPush
|
||||||
|
|
|
@ -36,7 +36,7 @@ import {NO_CHANGE} from '../tokens';
|
||||||
import {isAnimationProp} from '../util/attrs_utils';
|
import {isAnimationProp} from '../util/attrs_utils';
|
||||||
import {INTERPOLATION_DELIMITER, renderStringify, stringifyForError} from '../util/misc_utils';
|
import {INTERPOLATION_DELIMITER, renderStringify, stringifyForError} from '../util/misc_utils';
|
||||||
import {getLViewParent} from '../util/view_traversal_utils';
|
import {getLViewParent} from '../util/view_traversal_utils';
|
||||||
import {getComponentViewByIndex, getNativeByIndex, getNativeByTNode, getTNode, isCreationMode, readPatchedLView, resetPreOrderHookFlags, unwrapRNode, viewAttachedToChangeDetector} from '../util/view_utils';
|
import {getComponentLViewByIndex, getNativeByIndex, getNativeByTNode, getTNode, isCreationMode, readPatchedLView, resetPreOrderHookFlags, unwrapRNode, viewAttachedToChangeDetector} from '../util/view_utils';
|
||||||
|
|
||||||
import {selectIndexInternal} from './advance';
|
import {selectIndexInternal} from './advance';
|
||||||
import {LCleanup, LViewBlueprint, MatchesArray, TCleanup, TNodeConstructor, TNodeInitialInputs, TNodeLocalNames, TViewComponents, TViewConstructor, attachLContainerDebug, attachLViewDebug, cloneToLView, cloneToTViewData} from './lview_debug';
|
import {LCleanup, LViewBlueprint, MatchesArray, TCleanup, TNodeConstructor, TNodeInitialInputs, TNodeLocalNames, TViewComponents, TViewConstructor, attachLContainerDebug, attachLViewDebug, cloneToLView, cloneToTViewData} from './lview_debug';
|
||||||
|
@ -936,7 +936,7 @@ export function elementPropertyInternal<T>(
|
||||||
/** If node is an OnPush component, marks its LView dirty. */
|
/** If node is an OnPush component, marks its LView dirty. */
|
||||||
function markDirtyIfOnPush(lView: LView, viewIndex: number): void {
|
function markDirtyIfOnPush(lView: LView, viewIndex: number): void {
|
||||||
ngDevMode && assertLView(lView);
|
ngDevMode && assertLView(lView);
|
||||||
const childComponentLView = getComponentViewByIndex(viewIndex, lView);
|
const childComponentLView = getComponentLViewByIndex(viewIndex, lView);
|
||||||
if (!(childComponentLView[FLAGS] & LViewFlags.CheckAlways)) {
|
if (!(childComponentLView[FLAGS] & LViewFlags.CheckAlways)) {
|
||||||
childComponentLView[FLAGS] |= LViewFlags.Dirty;
|
childComponentLView[FLAGS] |= LViewFlags.Dirty;
|
||||||
}
|
}
|
||||||
|
@ -1185,7 +1185,7 @@ function postProcessDirective<T>(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isComponentDef(def)) {
|
if (isComponentDef(def)) {
|
||||||
const componentView = getComponentViewByIndex(hostTNode.index, lView);
|
const componentView = getComponentLViewByIndex(hostTNode.index, lView);
|
||||||
componentView[CONTEXT] = directive;
|
componentView[CONTEXT] = directive;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1502,7 +1502,7 @@ function refreshDynamicEmbeddedViews(lView: LView) {
|
||||||
*/
|
*/
|
||||||
function refreshComponent(hostLView: LView, componentHostIdx: number): void {
|
function refreshComponent(hostLView: LView, componentHostIdx: number): void {
|
||||||
ngDevMode && assertEqual(isCreationMode(hostLView), false, 'Should be run in update mode');
|
ngDevMode && assertEqual(isCreationMode(hostLView), false, 'Should be run in update mode');
|
||||||
const componentView = getComponentViewByIndex(componentHostIdx, hostLView);
|
const componentView = getComponentLViewByIndex(componentHostIdx, hostLView);
|
||||||
// Only attached components that are CheckAlways or OnPush and dirty should be refreshed
|
// Only attached components that are CheckAlways or OnPush and dirty should be refreshed
|
||||||
if (viewAttachedToChangeDetector(componentView) &&
|
if (viewAttachedToChangeDetector(componentView) &&
|
||||||
componentView[FLAGS] & (LViewFlags.CheckAlways | LViewFlags.Dirty)) {
|
componentView[FLAGS] & (LViewFlags.CheckAlways | LViewFlags.Dirty)) {
|
||||||
|
@ -1513,7 +1513,7 @@ function refreshComponent(hostLView: LView, componentHostIdx: number): void {
|
||||||
|
|
||||||
function renderComponent(hostLView: LView, componentHostIdx: number) {
|
function renderComponent(hostLView: LView, componentHostIdx: number) {
|
||||||
ngDevMode && assertEqual(isCreationMode(hostLView), true, 'Should be run in creation mode');
|
ngDevMode && assertEqual(isCreationMode(hostLView), true, 'Should be run in creation mode');
|
||||||
const componentView = getComponentViewByIndex(componentHostIdx, hostLView);
|
const componentView = getComponentLViewByIndex(componentHostIdx, hostLView);
|
||||||
syncViewWithBlueprint(componentView);
|
syncViewWithBlueprint(componentView);
|
||||||
renderView(componentView, componentView[TVIEW], componentView[CONTEXT]);
|
renderView(componentView, componentView[TVIEW], componentView[CONTEXT]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,7 +129,7 @@ export function load<T>(view: LView | TData, index: number): T {
|
||||||
return view[index + HEADER_OFFSET];
|
return view[index + HEADER_OFFSET];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getComponentViewByIndex(nodeIndex: number, hostView: LView): LView {
|
export function getComponentLViewByIndex(nodeIndex: number, hostView: LView): LView {
|
||||||
// Could be an LView or an LContainer. If LContainer, unwrap to find LView.
|
// Could be an LView or an LContainer. If LContainer, unwrap to find LView.
|
||||||
ngDevMode && assertDataInRange(hostView, nodeIndex);
|
ngDevMode && assertDataInRange(hostView, nodeIndex);
|
||||||
const slotValue = hostView[nodeIndex];
|
const slotValue = hostView[nodeIndex];
|
||||||
|
|
|
@ -32,7 +32,7 @@ import {getParentInjectorTNode} from './node_util';
|
||||||
import {getLView, getPreviousOrParentTNode} from './state';
|
import {getLView, getPreviousOrParentTNode} from './state';
|
||||||
import {getParentInjectorView, hasParentInjector} from './util/injector_utils';
|
import {getParentInjectorView, hasParentInjector} from './util/injector_utils';
|
||||||
import {findComponentView} from './util/view_traversal_utils';
|
import {findComponentView} from './util/view_traversal_utils';
|
||||||
import {getComponentViewByIndex, getNativeByTNode, unwrapRNode, viewAttachedToContainer} from './util/view_utils';
|
import {getComponentLViewByIndex, getNativeByTNode, unwrapRNode, viewAttachedToContainer} from './util/view_utils';
|
||||||
import {ViewRef} from './view_ref';
|
import {ViewRef} from './view_ref';
|
||||||
|
|
||||||
|
|
||||||
|
@ -379,7 +379,7 @@ function createViewRef(
|
||||||
hostTNode: TNode, hostView: LView, isPipe: boolean): ViewEngine_ChangeDetectorRef {
|
hostTNode: TNode, hostView: LView, isPipe: boolean): ViewEngine_ChangeDetectorRef {
|
||||||
if (isComponentHost(hostTNode) && !isPipe) {
|
if (isComponentHost(hostTNode) && !isPipe) {
|
||||||
const componentIndex = hostTNode.directiveStart;
|
const componentIndex = hostTNode.directiveStart;
|
||||||
const componentView = getComponentViewByIndex(hostTNode.index, hostView);
|
const componentView = getComponentLViewByIndex(hostTNode.index, hostView);
|
||||||
return new ViewRef(componentView, null, componentIndex);
|
return new ViewRef(componentView, null, componentIndex);
|
||||||
} else if (
|
} else if (
|
||||||
hostTNode.type === TNodeType.Element || hostTNode.type === TNodeType.Container ||
|
hostTNode.type === TNodeType.Element || hostTNode.type === TNodeType.Container ||
|
||||||
|
@ -406,6 +406,6 @@ export function injectRenderer2(): Renderer2 {
|
||||||
// DI happens before we've entered its view, `getLView` will return the parent view instead.
|
// DI happens before we've entered its view, `getLView` will return the parent view instead.
|
||||||
const lView = getLView();
|
const lView = getLView();
|
||||||
const tNode = getPreviousOrParentTNode();
|
const tNode = getPreviousOrParentTNode();
|
||||||
const nodeAtIndex = getComponentViewByIndex(tNode.index, lView);
|
const nodeAtIndex = getComponentLViewByIndex(tNode.index, lView);
|
||||||
return getOrCreateRenderer2(isLView(nodeAtIndex) ? nodeAtIndex : lView);
|
return getOrCreateRenderer2(isLView(nodeAtIndex) ? nodeAtIndex : lView);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue