MCPcopy Index your code
hub / github.com/angular/angular / selectIndexInternal

Function selectIndexInternal

packages/core/src/render3/instructions/advance.ts:53–84  ·  view source on GitHub ↗
(
  tView: TView,
  lView: LView,
  index: number,
  checkNoChangesMode: boolean,
)

Source from the content-addressed store, hash-verified

51}
52
53export function selectIndexInternal(
54 tView: TView,
55 lView: LView,
56 index: number,
57 checkNoChangesMode: boolean,
58) {
59 ngDevMode && assertIndexInDeclRange(lView[TVIEW], index);
60
61 // Flush the initial hooks for elements in the view that have been added up to this point.
62 // PERF WARNING: do NOT extract this to a separate function without running benchmarks
63 if (!checkNoChangesMode) {
64 const hooksInitPhaseCompleted =
65 (lView[FLAGS] & LViewFlags.InitPhaseStateMask) === InitPhaseState.InitPhaseCompleted;
66 if (hooksInitPhaseCompleted) {
67 const preOrderCheckHooks = tView.preOrderCheckHooks;
68 if (preOrderCheckHooks !== null) {
69 executeCheckHooks(lView, preOrderCheckHooks, index);
70 }
71 } else {
72 const preOrderHooks = tView.preOrderHooks;
73 if (preOrderHooks !== null) {
74 executeInitAndCheckHooks(lView, preOrderHooks, InitPhaseState.OnInitHooksToBeRun, index);
75 }
76 }
77 }
78
79 // We must set the selected index *after* running the hooks, because hooks may have side-effects
80 // that cause other template functions to run, thus updating the selected index, which is global
81 // state. If we run `setSelectedIndex` *before* we run the hooks, in some cases the selected index
82 // will be altered by the time we leave the `ɵɵadvance` instruction.
83 setSelectedIndex(index);
84}

Callers 2

executeTemplateFunction · 0.90
ɵɵadvanceFunction · 0.85

Calls 4

assertIndexInDeclRangeFunction · 0.90
executeCheckHooksFunction · 0.90
executeInitAndCheckHooksFunction · 0.90
setSelectedIndexFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…