@@ -13,7 +13,6 @@ import {
13
13
Type ,
14
14
ViewChild ,
15
15
inject ,
16
- TrackByFunction ,
17
16
} from '@angular/core' ;
18
17
import { By } from '@angular/platform-browser' ;
19
18
import { ComponentFixture , TestBed , fakeAsync , flush , waitForAsync } from '@angular/core/testing' ;
@@ -1996,35 +1995,6 @@ describe('CdkTable', () => {
1996
1995
expect ( noDataRow ) . toBeTruthy ( ) ;
1997
1996
expect ( noDataRow . getAttribute ( 'colspan' ) ) . toEqual ( '3' ) ;
1998
1997
} ) ;
1999
-
2000
- it ( 'should properly update table content when data changes in OnPush component with track by instance' , ( ) => {
2001
- setupTableTestApp ( WrapNativeTrackByHtmlTableAppOnPush ) ;
2002
-
2003
- const data = component . dataSource . data ;
2004
-
2005
- expectTableToMatchContent ( tableElement , [
2006
- [ 'Column A' , 'Column B' , 'Column C' ] ,
2007
- [ data [ 0 ] . a , data [ 0 ] . b , data [ 0 ] . c ] ,
2008
- [ data [ 1 ] . a , data [ 1 ] . b , data [ 1 ] . c ] ,
2009
- [ data [ 2 ] . a , data [ 2 ] . b , data [ 2 ] . c ] ,
2010
- ] ) ;
2011
-
2012
- component . dataSource . data = component . dataSource . data . map ( ( data : TestData ) => ( {
2013
- ...data ,
2014
- b : `${ data . b } -updated` ,
2015
- } ) ) ;
2016
-
2017
- fixture . detectChanges ( ) ;
2018
-
2019
- const newData = component . dataSource . data ;
2020
-
2021
- expectTableToMatchContent ( tableElement , [
2022
- [ 'Column A' , 'Column B' , 'Column C' ] ,
2023
- [ newData [ 0 ] . a , newData [ 0 ] . b , newData [ 0 ] . c ] ,
2024
- [ newData [ 1 ] . a , newData [ 1 ] . b , newData [ 1 ] . c ] ,
2025
- [ newData [ 2 ] . a , newData [ 2 ] . b , newData [ 2 ] . c ] ,
2026
- ] ) ;
2027
- } ) ;
2028
1998
} ) ;
2029
1999
2030
2000
interface TestData {
@@ -3165,7 +3135,7 @@ class TableWithIndirectDescendantDefs {
3165
3135
@Component ( {
3166
3136
selector : 'cdk-table-change-detection-on-push' ,
3167
3137
template : `
3168
- <table cdk-table [dataSource]="dataSource" [trackBy]="trackBy" >
3138
+ <table cdk-table [dataSource]="dataSource">
3169
3139
<ng-container cdkColumnDef="column_a">
3170
3140
<th cdk-header-cell *cdkHeaderCellDef> Column A</th>
3171
3141
<td cdk-cell *cdkCellDef="let row"> {{row.a}}</td>
@@ -3193,7 +3163,6 @@ class TableWithIndirectDescendantDefs {
3193
3163
} )
3194
3164
class NativeHtmlTableAppOnPush {
3195
3165
@Input ( ) dataSource : Observable < TestData [ ] > | null = null ;
3196
- @Input ( ) trackBy : TrackByFunction < TestData > | undefined ;
3197
3166
columnsToRender = [ 'column_a' , 'column_b' , 'column_c' ] ;
3198
3167
}
3199
3168
@@ -3207,17 +3176,6 @@ class WrapNativeHtmlTableAppOnPush {
3207
3176
dataSource : FakeDataSource = new FakeDataSource ( ) ;
3208
3177
}
3209
3178
3210
- @Component ( {
3211
- template : `
3212
- <cdk-table-change-detection-on-push [dataSource]="dataSource" [trackBy]="trackBy"></cdk-table-change-detection-on-push>
3213
- ` ,
3214
- imports : [ NativeHtmlTableAppOnPush ] ,
3215
- } )
3216
- class WrapNativeTrackByHtmlTableAppOnPush {
3217
- dataSource : FakeDataSource = new FakeDataSource ( ) ;
3218
- trackBy : TrackByFunction < TestData > = ( index : number , data : TestData ) => data . a ;
3219
- }
3220
-
3221
3179
function getElements ( element : Element , query : string ) : HTMLElement [ ] {
3222
3180
return [ ] . slice . call ( element . querySelectorAll ( query ) ) ;
3223
3181
}
0 commit comments