Skip to content

Commit 1f77083

Browse files
pkozlowski-opensourceatscott
authored andcommitted
refactor(core): assert presence of the track function (#54814)
This commits assert that the repeater instruction gets a reference to a tracking function. This change will allow us to better track occurences of #53628 - in certain situations a reference to a tracking function might be undefiened. We are not fixing the underlying issue here, just getting better visibility. PR Close #54814
1 parent bb35414 commit 1f77083

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {setActiveConsumer} from '@angular/core/primitives/signals';
1111
import {TrackByFunction} from '../../change_detection';
1212
import {DehydratedContainerView} from '../../hydration/interfaces';
1313
import {findMatchingDehydratedView} from '../../hydration/views';
14-
import {assertDefined} from '../../util/assert';
14+
import {assertDefined, assertFunction} from '../../util/assert';
1515
import {performanceMarkFeature} from '../../util/performance';
1616
import {assertLContainer, assertLView, assertTNode} from '../assert';
1717
import {bindingUpdated} from '../bindings';
@@ -150,6 +150,11 @@ export function ɵɵrepeaterCreate(
150150
emptyDecls?: number, emptyVars?: number, emptyTagName?: string|null,
151151
emptyAttrsIndex?: number|null): void {
152152
performanceMarkFeature('NgControlFlow');
153+
154+
ngDevMode &&
155+
assertFunction(
156+
trackByFn, `A track expression must be a function, was ${typeof trackByFn} instead.`);
157+
153158
const hasEmptyBlock = emptyTemplateFn !== undefined;
154159
const hostLView = getLView();
155160
const boundTrackBy = trackByUsesComponentInstance ?

0 commit comments

Comments
 (0)