({
lView,
slotIdx,
}: ControlFlowBlockViewFinderConfig)
| 164 | * @returns |
| 165 | */ |
| 166 | const 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. |
| 213 | const CONTROL_FLOW_BLOCK_FINDERS: ControlFlowBlockViewFinder[] = [deferBlockFinder, forLoopFinder]; |
nothing calls this directly
no test coverage detected
searching dependent graphs…