Skip to content

Commit 075d680

Browse files
committed
comments
1 parent 09958b0 commit 075d680

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/cdk/table/table.spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,7 @@ describe('CdkTable', () => {
171171
expect(changedRows[2].getAttribute('initialIndex')).toBe(null);
172172
});
173173

174-
it('when the data is homogeneous', () => {
175-
// Change default data to be one that is a list of homogeneous data.
174+
it('when the data contains multiple occurrences of the same object instance', () => {
176175
const obj = {value: true};
177176
component.dataSource!.data = [obj, obj, obj];
178177
addInitialIndexAttribute();

src/cdk/table/table.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ export class CdkTable<T> implements CollectionViewer, OnInit, AfterContentChecke
504504
}
505505

506506
/**
507-
* Returns a list of `RenderRow<T>` for the provided data object and any `CdkRowDef` objects that
507+
* Gets a list of `RenderRow<T>` for the provided data object and any `CdkRowDef` objects that
508508
* should be rendered for this data. Reuses the cached RenderRow objects if they match the same
509509
* `(T, CdkRowDef)` pair.
510510
*/
@@ -665,14 +665,15 @@ export class CdkTable<T> implements CollectionViewer, OnInit, AfterContentChecke
665665
* predicate that returns true with the data. If none return true, return the default row
666666
* definition.
667667
*/
668-
_getRowDefs(data: T, i: number): CdkRowDef<T>[] {
668+
_getRowDefs(data: T, dataIndex: number): CdkRowDef<T>[] {
669669
if (this._rowDefs.length == 1) { return [this._rowDefs[0]]; }
670670

671671
let rowDefs: CdkRowDef<T>[] = [];
672672
if (this.multiTemplateDataRows) {
673-
rowDefs = this._rowDefs.filter(def => !def.when || def.when(i, data));
673+
rowDefs = this._rowDefs.filter(def => !def.when || def.when(dataIndex, data));
674674
} else {
675-
let rowDef = this._rowDefs.find(def => def.when && def.when(i, data)) || this._defaultRowDef;
675+
let rowDef =
676+
this._rowDefs.find(def => def.when && def.when(dataIndex, data)) || this._defaultRowDef;
676677
if (rowDef) {
677678
rowDefs.push(rowDef);
678679
}

0 commit comments

Comments
 (0)