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

Function forLoopFinder

packages/core/src/render3/util/control_flow.ts:166–210  ·  view source on GitHub ↗
({
  lView,
  slotIdx,
}: ControlFlowBlockViewFinderConfig)

Source from the content-addressed store, hash-verified

164 * @returns
165 */
166const forLoopFinder: ControlFlowBlockViewFinder = ({
167 lView,
168 slotIdx,
169}: ControlFlowBlockViewFinderConfig) => {
170 const slot = lView[slotIdx];
171
172 if (!isRepeaterMetadata(slot)) {
173 return null;
174 }
175
176 const metadata = slot;
177 const liveCollection = metadata.liveCollection;
178 const items: unknown[] = [];
179
180 if (liveCollection) {
181 for (let j = 0; j < liveCollection.length; j++) {
182 items.push(liveCollection.at(j));
183 }
184 }
185
186 const containerIndex = slotIdx + 1;
187 const lContainer = lView[containerIndex];
188 const rootNodes: Node[] = [];
189
190 if (isLContainer(lContainer)) {
191 // Collect root nodes from each view in the container
192 for (let viewIdx = CONTAINER_HEADER_OFFSET; viewIdx < lContainer.length; viewIdx++) {
193 const viewAtIdx = lContainer[viewIdx];
194 if (isLView(viewAtIdx)) {
195 const viewTView = viewAtIdx[TVIEW];
196 const viewNodes = collectNativeNodes(viewTView, viewAtIdx, viewTView.firstChild, []);
197 rootNodes.push(...viewNodes);
198 }
199 }
200 }
201
202 return {
203 type: ControlFlowBlockType.For,
204 items,
205 hasEmptyBlock: metadata.hasEmptyBlock,
206 rootNodes,
207 hostNode: lContainer[HOST] as Node,
208 trackExpression: getTrackExpression(metadata),
209 } satisfies ForLoopBlockData;
210};
211
212// Represents all supported control flow block finders.
213const CONTROL_FLOW_BLOCK_FINDERS: ControlFlowBlockViewFinder[] = [deferBlockFinder, forLoopFinder];

Callers

nothing calls this directly

Calls 7

isLContainerFunction · 0.90
isLViewFunction · 0.90
collectNativeNodesFunction · 0.90
isRepeaterMetadataFunction · 0.85
getTrackExpressionFunction · 0.85
pushMethod · 0.45
atMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…