Skip to content

Commit 9d51982

Browse files
committed
fixup! refactor(core): abstract control flow discovery utilities
1 parent abc5771 commit 9d51982

2 files changed

Lines changed: 15 additions & 13 deletions

File tree

packages/core/src/render3/util/control_flow.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,15 @@ import {TNode} from '../interfaces/node';
4848
/**
4949
* Gets all of the control flow blocks that are present inside the specified DOM node.
5050
* @param node Node in which to look for control flow blocks.
51-
*
52-
* @publicApi
5351
*/
5452
export function getControlFlowBlocks(node: Node): ControlFlowBlock[] {
55-
const results: ControlFlowBlock[] = [];
5653
const lView = getLContext(node)?.lView;
5754

5855
if (lView) {
59-
findControlFlowBlocks(node, lView, results);
56+
return findControlFlowBlocks(node, lView);
6057
}
6158

62-
return results;
59+
return [];
6360
}
6461

6562
/**
@@ -91,8 +88,6 @@ const deferBlockFinder: ControlFlowBlockViewFinder = ({
9188
const tDetails = getTDeferBlockDetails(tView, tNode);
9289

9390
if (isTDeferBlockDetails(tDetails)) {
94-
// return {lContainer, lView, tNode, tDetails};
95-
9691
const native = getNativeByTNode(tNode, lView);
9792
const lDetails = getLDeferBlockDetails(lView, tNode);
9893

@@ -222,9 +217,14 @@ const CONTROL_FLOW_BLOCK_FINDERS: ControlFlowBlockViewFinder[] = [deferBlockFind
222217
*
223218
* @param node Node in which to search for blocks.
224219
* @param lView View within the node in which to search for blocks.
225-
* @param results Array to which to add blocks once they're found.
220+
* @param results (Optional) Array to which to add blocks once they're found.
221+
* @returns Found control flow blocks results array.
226222
*/
227-
function findControlFlowBlocks(node: Node, lView: LView, results: ControlFlowBlock[]) {
223+
function findControlFlowBlocks(
224+
node: Node,
225+
lView: LView,
226+
results: ControlFlowBlock[] = [],
227+
): ControlFlowBlock[] {
228228
const tView = lView[TVIEW];
229229

230230
for (let i = HEADER_OFFSET; i < tView.bindingStartIndex; i++) {
@@ -255,6 +255,8 @@ function findControlFlowBlocks(node: Node, lView: LView, results: ControlFlowBlo
255255
findControlFlowBlocks(node, slot, results);
256256
}
257257
}
258+
259+
return results;
258260
}
259261

260262
/**

packages/core/src/render3/util/control_flow_types.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,16 +93,16 @@ export interface ControlFlowBlockViewFinderConfig {
9393
/**
9494
* Describes a finder function that extracts `ControlFlowBlock`s from an LView.
9595
*/
96-
export interface ControlFlowBlockViewFinder {
97-
(config: ControlFlowBlockViewFinderConfig): ControlFlowBlock | null;
98-
}
96+
export type ControlFlowBlockViewFinder = (
97+
config: ControlFlowBlockViewFinderConfig,
98+
) => ControlFlowBlock | null;
9999

100100
/**
101101
* Represents `RepeaterMetadata` data mirror.
102+
* Required due to a circular dependency.
102103
*/
103104
export interface RepeaterMetadataShape {
104105
hasEmptyBlock: boolean;
105106
trackByFn: TrackByFunction<unknown>;
106107
liveCollection?: LiveCollection<unknown, unknown>;
107-
originalTrackByFn?: TrackByFunction<unknown>;
108108
}

0 commit comments

Comments
 (0)