Skip to content

Commit f1ffd57

Browse files
mheverykara
authored andcommitted
refactor(ivy): rename getComponentViewByIndex to getComponentLViewByIndex (angular#33074)
PR Close angular#33074
1 parent 7f7dc7c commit f1ffd57

File tree

6 files changed

+18
-18
lines changed

6 files changed

+18
-18
lines changed

packages/core/src/debug/debug_node.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {getComponent, getContext, getInjectionTokens, getInjector, getListeners,
1818
import {INTERPOLATION_DELIMITER, renderStringify} from '../render3/util/misc_utils';
1919
import {isStylingContext, stylingMapToStringMap} from '../render3/util/styling_utils';
2020
import {findComponentView} from '../render3/util/view_traversal_utils';
21-
import {getComponentViewByIndex, getNativeByTNodeOrNull} from '../render3/util/view_utils';
21+
import {getComponentLViewByIndex, getNativeByTNodeOrNull} from '../render3/util/view_utils';
2222
import {assertDomNode} from '../util/assert';
2323
import {DebugContext} from '../view/index';
2424
import {createProxy} from './proxy';
@@ -494,7 +494,7 @@ function _queryNodeChildrenR3(
494494
if (isComponentHost(tNode)) {
495495
// If the element is the host of a component, then all nodes in its view have to be processed.
496496
// Note: the component's content (tNode.child) will be processed from the insertion points.
497-
const componentView = getComponentViewByIndex(tNode.index, lView);
497+
const componentView = getComponentLViewByIndex(tNode.index, lView);
498498
if (componentView && componentView[TVIEW].firstChild) {
499499
_queryNodeChildrenR3(
500500
componentView[TVIEW].firstChild !, componentView, predicate, matches, elementsOnly,

packages/core/src/render3/context_discovery.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {LContext, MONKEY_PATCH_KEY_NAME} from './interfaces/context';
1414
import {TNode, TNodeFlags} from './interfaces/node';
1515
import {RElement, RNode} from './interfaces/renderer';
1616
import {CONTEXT, HEADER_OFFSET, HOST, LView, TVIEW} from './interfaces/view';
17-
import {getComponentViewByIndex, getNativeByTNodeOrNull, readPatchedData, unwrapRNode} from './util/view_utils';
17+
import {getComponentLViewByIndex, getNativeByTNodeOrNull, readPatchedData, unwrapRNode} from './util/view_utils';
1818

1919

2020

@@ -157,14 +157,14 @@ export function getComponentViewByInstance(componentInstance: {}): LView {
157157

158158
if (Array.isArray(lView)) {
159159
const nodeIndex = findViaComponent(lView, componentInstance);
160-
view = getComponentViewByIndex(nodeIndex, lView);
160+
view = getComponentLViewByIndex(nodeIndex, lView);
161161
const context = createLContext(lView, nodeIndex, view[HOST] as RElement);
162162
context.component = componentInstance;
163163
attachPatchData(componentInstance, context);
164164
attachPatchData(context.native, context);
165165
} else {
166166
const context = lView as any as LContext;
167-
view = getComponentViewByIndex(context.nodeIndex, context.lView);
167+
view = getComponentLViewByIndex(context.nodeIndex, context.lView);
168168
}
169169
return view;
170170
}
@@ -228,13 +228,13 @@ function findViaComponent(lView: LView, componentInstance: {}): number {
228228
if (componentIndices) {
229229
for (let i = 0; i < componentIndices.length; i++) {
230230
const elementComponentIndex = componentIndices[i];
231-
const componentView = getComponentViewByIndex(elementComponentIndex, lView);
231+
const componentView = getComponentLViewByIndex(elementComponentIndex, lView);
232232
if (componentView[CONTEXT] === componentInstance) {
233233
return elementComponentIndex;
234234
}
235235
}
236236
} else {
237-
const rootComponentView = getComponentViewByIndex(HEADER_OFFSET, lView);
237+
const rootComponentView = getComponentLViewByIndex(HEADER_OFFSET, lView);
238238
const rootComponent = rootComponentView[CONTEXT];
239239
if (rootComponent === componentInstance) {
240240
// we are dealing with the root element here therefore we know that the

packages/core/src/render3/instructions/listener.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {isDirectiveHost} from '../interfaces/type_checks';
1616
import {CLEANUP, FLAGS, LView, LViewFlags, RENDERER, TVIEW} from '../interfaces/view';
1717
import {assertNodeOfPossibleTypes} from '../node_assert';
1818
import {getLView, getPreviousOrParentTNode} from '../state';
19-
import {getComponentViewByIndex, getNativeByTNode, unwrapRNode} from '../util/view_utils';
19+
import {getComponentLViewByIndex, getNativeByTNode, unwrapRNode} from '../util/view_utils';
2020
import {getCleanup, handleError, loadComponentRenderer, markViewDirty} from './shared';
2121

2222
/**
@@ -248,7 +248,7 @@ function wrapListener(
248248
// In order to be backwards compatible with View Engine, events on component host nodes
249249
// must also mark the component view itself dirty (i.e. the view that it owns).
250250
const startView = tNode.flags & TNodeFlags.isComponentHost ?
251-
getComponentViewByIndex(tNode.index, lView) :
251+
getComponentLViewByIndex(tNode.index, lView) :
252252
lView;
253253

254254
// See interfaces/view.ts for more on LViewFlags.ManualOnPush

packages/core/src/render3/instructions/shared.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import {NO_CHANGE} from '../tokens';
3636
import {isAnimationProp} from '../util/attrs_utils';
3737
import {INTERPOLATION_DELIMITER, renderStringify, stringifyForError} from '../util/misc_utils';
3838
import {getLViewParent} from '../util/view_traversal_utils';
39-
import {getComponentViewByIndex, getNativeByIndex, getNativeByTNode, getTNode, isCreationMode, readPatchedLView, resetPreOrderHookFlags, unwrapRNode, viewAttachedToChangeDetector} from '../util/view_utils';
39+
import {getComponentLViewByIndex, getNativeByIndex, getNativeByTNode, getTNode, isCreationMode, readPatchedLView, resetPreOrderHookFlags, unwrapRNode, viewAttachedToChangeDetector} from '../util/view_utils';
4040

4141
import {selectIndexInternal} from './advance';
4242
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>(
936936
/** If node is an OnPush component, marks its LView dirty. */
937937
function markDirtyIfOnPush(lView: LView, viewIndex: number): void {
938938
ngDevMode && assertLView(lView);
939-
const childComponentLView = getComponentViewByIndex(viewIndex, lView);
939+
const childComponentLView = getComponentLViewByIndex(viewIndex, lView);
940940
if (!(childComponentLView[FLAGS] & LViewFlags.CheckAlways)) {
941941
childComponentLView[FLAGS] |= LViewFlags.Dirty;
942942
}
@@ -1185,7 +1185,7 @@ function postProcessDirective<T>(
11851185
}
11861186

11871187
if (isComponentDef(def)) {
1188-
const componentView = getComponentViewByIndex(hostTNode.index, lView);
1188+
const componentView = getComponentLViewByIndex(hostTNode.index, lView);
11891189
componentView[CONTEXT] = directive;
11901190
}
11911191
}
@@ -1502,7 +1502,7 @@ function refreshDynamicEmbeddedViews(lView: LView) {
15021502
*/
15031503
function refreshComponent(hostLView: LView, componentHostIdx: number): void {
15041504
ngDevMode && assertEqual(isCreationMode(hostLView), false, 'Should be run in update mode');
1505-
const componentView = getComponentViewByIndex(componentHostIdx, hostLView);
1505+
const componentView = getComponentLViewByIndex(componentHostIdx, hostLView);
15061506
// Only attached components that are CheckAlways or OnPush and dirty should be refreshed
15071507
if (viewAttachedToChangeDetector(componentView) &&
15081508
componentView[FLAGS] & (LViewFlags.CheckAlways | LViewFlags.Dirty)) {
@@ -1513,7 +1513,7 @@ function refreshComponent(hostLView: LView, componentHostIdx: number): void {
15131513

15141514
function renderComponent(hostLView: LView, componentHostIdx: number) {
15151515
ngDevMode && assertEqual(isCreationMode(hostLView), true, 'Should be run in creation mode');
1516-
const componentView = getComponentViewByIndex(componentHostIdx, hostLView);
1516+
const componentView = getComponentLViewByIndex(componentHostIdx, hostLView);
15171517
syncViewWithBlueprint(componentView);
15181518
renderView(componentView, componentView[TVIEW], componentView[CONTEXT]);
15191519
}

packages/core/src/render3/util/view_utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ export function load<T>(view: LView | TData, index: number): T {
129129
return view[index + HEADER_OFFSET];
130130
}
131131

132-
export function getComponentViewByIndex(nodeIndex: number, hostView: LView): LView {
132+
export function getComponentLViewByIndex(nodeIndex: number, hostView: LView): LView {
133133
// Could be an LView or an LContainer. If LContainer, unwrap to find LView.
134134
ngDevMode && assertDataInRange(hostView, nodeIndex);
135135
const slotValue = hostView[nodeIndex];

packages/core/src/render3/view_engine_compatibility.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import {getParentInjectorTNode} from './node_util';
3232
import {getLView, getPreviousOrParentTNode} from './state';
3333
import {getParentInjectorView, hasParentInjector} from './util/injector_utils';
3434
import {findComponentView} from './util/view_traversal_utils';
35-
import {getComponentViewByIndex, getNativeByTNode, unwrapRNode, viewAttachedToContainer} from './util/view_utils';
35+
import {getComponentLViewByIndex, getNativeByTNode, unwrapRNode, viewAttachedToContainer} from './util/view_utils';
3636
import {ViewRef} from './view_ref';
3737

3838

@@ -379,7 +379,7 @@ function createViewRef(
379379
hostTNode: TNode, hostView: LView, isPipe: boolean): ViewEngine_ChangeDetectorRef {
380380
if (isComponentHost(hostTNode) && !isPipe) {
381381
const componentIndex = hostTNode.directiveStart;
382-
const componentView = getComponentViewByIndex(hostTNode.index, hostView);
382+
const componentView = getComponentLViewByIndex(hostTNode.index, hostView);
383383
return new ViewRef(componentView, null, componentIndex);
384384
} else if (
385385
hostTNode.type === TNodeType.Element || hostTNode.type === TNodeType.Container ||
@@ -406,6 +406,6 @@ export function injectRenderer2(): Renderer2 {
406406
// DI happens before we've entered its view, `getLView` will return the parent view instead.
407407
const lView = getLView();
408408
const tNode = getPreviousOrParentTNode();
409-
const nodeAtIndex = getComponentViewByIndex(tNode.index, lView);
409+
const nodeAtIndex = getComponentLViewByIndex(tNode.index, lView);
410410
return getOrCreateRenderer2(isLView(nodeAtIndex) ? nodeAtIndex : lView);
411411
}

0 commit comments

Comments
 (0)