MCPcopy Create free account
hub / github.com/angular/angular / executeTemplate

Function executeTemplate

packages/core/src/render3/instructions/shared.ts:90–120  ·  view source on GitHub ↗
(
  tView: TView,
  lView: LView<T>,
  templateFn: ComponentTemplate<T>,
  rf: RenderFlags,
  context: T,
)

Source from the content-addressed store, hash-verified

88import {writeToDirectiveInput} from './write_to_directive_input';
89
90export function executeTemplate<T>(
91 tView: TView,
92 lView: LView<T>,
93 templateFn: ComponentTemplate<T>,
94 rf: RenderFlags,
95 context: T,
96) {
97 const prevSelectedIndex = getSelectedIndex();
98 const isUpdatePhase = rf & RenderFlags.Update;
99 try {
100 setSelectedIndex(-1);
101 if (isUpdatePhase && lView.length > HEADER_OFFSET) {
102 // When we're updating, inherently select 0 so we don't
103 // have to generate that instruction for most update blocks.
104 selectIndexInternal(tView, lView, HEADER_OFFSET, !!ngDevMode && isInCheckNoChangesMode());
105 }
106
107 const preHookType = isUpdatePhase
108 ? ProfilerEvent.TemplateUpdateStart
109 : ProfilerEvent.TemplateCreateStart;
110 profiler(preHookType, context as unknown as {}, templateFn);
111 templateFn(rf, context);
112 } finally {
113 setSelectedIndex(prevSelectedIndex);
114
115 const postHookType = isUpdatePhase
116 ? ProfilerEvent.TemplateUpdateEnd
117 : ProfilerEvent.TemplateCreateEnd;
118 profiler(postHookType, context as unknown as {}, templateFn);
119 }
120}
121
122/**
123 * Creates directive instances.

Callers 2

renderViewFunction · 0.90
refreshViewFunction · 0.90

Calls 5

getSelectedIndexFunction · 0.90
setSelectedIndexFunction · 0.90
selectIndexInternalFunction · 0.90
isInCheckNoChangesModeFunction · 0.90
profilerFunction · 0.90

Tested by

no test coverage detected