fix(common): throw an error if trackBy is not a function (#13420)
* fix(common): throw an error if trackBy is not a function Closes #13388 * refactor(platform-browser): disable no-console rule in DomAdapter
This commit is contained in:

committed by
Chuck Jazdzewski

parent
b9e979e0a5
commit
44e84d87f9
@ -294,6 +294,16 @@ export function main() {
|
||||
}));
|
||||
|
||||
describe('track by', () => {
|
||||
it('should throw if trackBy is not a function', async(() => {
|
||||
const template =
|
||||
`<template ngFor let-item [ngForOf]="items" [ngForTrackBy]="item?.id"></template>`;
|
||||
fixture = createTestComponent(template);
|
||||
|
||||
getComponent().items = [{id: 1}, {id: 2}];
|
||||
expect(() => fixture.detectChanges())
|
||||
.toThrowError(/trackBy must be a function, but received null/);
|
||||
}));
|
||||
|
||||
it('should set the context to the component instance', async(() => {
|
||||
const template =
|
||||
`<template ngFor let-item [ngForOf]="items" [ngForTrackBy]="trackByContext.bind(this)"></template>`;
|
||||
|
Reference in New Issue
Block a user