MCPcopy Create free account
hub / github.com/angular/angular / ɵɵrepeaterCreate

Function ɵɵrepeaterCreate

packages/core/src/render3/instructions/control_flow.ts:310–375  ·  view source on GitHub ↗
(
  index: number,
  templateFn: ComponentTemplate<unknown>,
  decls: number,
  vars: number,
  tagName: string | null,
  attrsIndex: number | null,
  trackByFn: TrackByFunction<unknown>,
  trackByUsesComponentInstance?: boolean,
  emptyTemplateFn?: ComponentTemplate<unknown>,
  emptyDecls?: number,
  emptyVars?: number,
  emptyTagName?: string | null,
  emptyAttrsIndex?: number | null,
)

Source from the content-addressed store, hash-verified

308 * @codeGenApi
309 */
310export function ɵɵrepeaterCreate(
311 index: number,
312 templateFn: ComponentTemplate<unknown>,
313 decls: number,
314 vars: number,
315 tagName: string | null,
316 attrsIndex: number | null,
317 trackByFn: TrackByFunction<unknown>,
318 trackByUsesComponentInstance?: boolean,
319 emptyTemplateFn?: ComponentTemplate<unknown>,
320 emptyDecls?: number,
321 emptyVars?: number,
322 emptyTagName?: string | null,
323 emptyAttrsIndex?: number | null,
324): void {
325 performanceMarkFeature('NgControlFlow');
326
327 ngDevMode &&
328 assertFunction(
329 trackByFn,
330 `A track expression must be a function, was ${typeof trackByFn} instead.`,
331 );
332
333 const lView = getLView();
334 const tView = getTView();
335 const hasEmptyBlock = emptyTemplateFn !== undefined;
336 const hostLView = getLView();
337 const boundTrackBy = trackByUsesComponentInstance
338 ? // We only want to bind when necessary, because it produces a
339 // new function. For pure functions it's not necessary.
340 trackByFn.bind(hostLView[DECLARATION_COMPONENT_VIEW][CONTEXT])
341 : trackByFn;
342 const metadata = new RepeaterMetadata(hasEmptyBlock, boundTrackBy);
343 hostLView[HEADER_OFFSET + index] = metadata;
344
345 declareNoDirectiveHostTemplate(
346 lView,
347 tView,
348 index + 1,
349 templateFn,
350 decls,
351 vars,
352 tagName,
353 getConstant(tView.consts, attrsIndex),
354 TNodeFlags.isControlFlowStart,
355 );
356
357 if (hasEmptyBlock) {
358 ngDevMode &&
359 assertDefined(emptyDecls, 'Missing number of declarations for the empty repeater block.');
360 ngDevMode &&
361 assertDefined(emptyVars, 'Missing number of bindings for the empty repeater block.');
362
363 declareNoDirectiveHostTemplate(
364 lView,
365 tView,
366 index + 2,
367 emptyTemplateFn,

Callers

nothing calls this directly

Calls 8

performanceMarkFeatureFunction · 0.90
assertFunctionFunction · 0.90
getLViewFunction · 0.90
getTViewFunction · 0.90
getConstantFunction · 0.90
assertDefinedFunction · 0.90
bindMethod · 0.65

Tested by

no test coverage detected