Skip to content

Commit

Permalink
refactor(core): assert presence of the track function (#54814)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
pkozlowski-opensource authored and atscott committed Mar 11, 2024
1 parent bb35414 commit 1f77083
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/core/src/render3/instructions/control_flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {setActiveConsumer} from '@angular/core/primitives/signals';
import {TrackByFunction} from '../../change_detection';
import {DehydratedContainerView} from '../../hydration/interfaces';
import {findMatchingDehydratedView} from '../../hydration/views';
import {assertDefined} from '../../util/assert';
import {assertDefined, assertFunction} from '../../util/assert';
import {performanceMarkFeature} from '../../util/performance';
import {assertLContainer, assertLView, assertTNode} from '../assert';
import {bindingUpdated} from '../bindings';
Expand Down Expand Up @@ -150,6 +150,11 @@ export function ɵɵrepeaterCreate(
emptyDecls?: number, emptyVars?: number, emptyTagName?: string|null,
emptyAttrsIndex?: number|null): void {
performanceMarkFeature('NgControlFlow');

ngDevMode &&
assertFunction(
trackByFn, `A track expression must be a function, was ${typeof trackByFn} instead.`);

const hasEmptyBlock = emptyTemplateFn !== undefined;
const hostLView = getLView();
const boundTrackBy = trackByUsesComponentInstance ?
Expand Down

0 comments on commit 1f77083

Please sign in to comment.