@@ -91,7 +91,7 @@ export class CdkTable<T> implements CollectionViewer {
91
91
private _renderChangeSubscription : Subscription ;
92
92
93
93
/** Map of all the user's defined columns (header and data cell template) identified by name. */
94
- private _columnDefinitionsMap = new Map < string , CdkColumnDef > ( ) ;
94
+ private _columnDefinitionsByName = new Map < string , CdkColumnDef > ( ) ;
95
95
96
96
/** Differ used to find the changes in the data provided by the data source. */
97
97
private _dataDiffer : IterableDiffer < T > ;
@@ -169,12 +169,12 @@ export class CdkTable<T> implements CollectionViewer {
169
169
170
170
ngAfterContentInit ( ) {
171
171
// Initialize the column definitions map for easy lookup. Update the map when changed.
172
- this . _refreshColumnDefinitionsMap ( ) ;
173
- this . _columnDefinitions . changes . subscribe ( ( ) => this . _refreshColumnDefinitionsMap ( ) ) ;
172
+ this . _cacheColumnDefinitionsByName ( ) ;
173
+ this . _columnDefinitions . changes . subscribe ( ( ) => this . _cacheColumnDefinitionsByName ( ) ) ;
174
174
}
175
175
176
176
ngAfterContentChecked ( ) {
177
- this . _checkColumnsChange ( ) ;
177
+ this . _renderUpdatedColumns ( ) ;
178
178
}
179
179
180
180
ngAfterViewInit ( ) {
@@ -199,21 +199,21 @@ export class CdkTable<T> implements CollectionViewer {
199
199
}
200
200
201
201
/** Update the map containing the content's column definitions. */
202
- private _refreshColumnDefinitionsMap ( ) {
203
- this . _columnDefinitionsMap . clear ( ) ;
202
+ private _cacheColumnDefinitionsByName ( ) {
203
+ this . _columnDefinitionsByName . clear ( ) ;
204
204
this . _columnDefinitions . forEach ( columnDef => {
205
- if ( this . _columnDefinitionsMap . has ( columnDef . name ) ) {
205
+ if ( this . _columnDefinitionsByName . has ( columnDef . name ) ) {
206
206
throw getTableDuplicateColumnNameError ( columnDef . name ) ;
207
207
}
208
- this . _columnDefinitionsMap . set ( columnDef . name , columnDef ) ;
208
+ this . _columnDefinitionsByName . set ( columnDef . name , columnDef ) ;
209
209
} ) ;
210
210
}
211
211
212
212
/**
213
213
* Check if the header or rows have changed what columns they want to display. If there is a diff,
214
214
* then re-render that section.
215
215
*/
216
- private _checkColumnsChange ( ) {
216
+ private _renderUpdatedColumns ( ) {
217
217
// Re-render the rows when the row definition columns change.
218
218
this . _rowDefinitions . forEach ( def => {
219
219
if ( ! ! def . getColumnsDiff ( ) ) {
@@ -360,7 +360,7 @@ export class CdkTable<T> implements CollectionViewer {
360
360
private _getHeaderCellTemplatesForRow ( headerDef : CdkHeaderRowDef ) : CdkHeaderCellDef [ ] {
361
361
if ( ! headerDef . columns ) { return [ ] ; }
362
362
return headerDef . columns . map ( columnId => {
363
- const column = this . _columnDefinitionsMap . get ( columnId ) ;
363
+ const column = this . _columnDefinitionsByName . get ( columnId ) ;
364
364
365
365
if ( ! column ) {
366
366
throw getTableUnknownColumnError ( columnId ) ;
@@ -377,7 +377,7 @@ export class CdkTable<T> implements CollectionViewer {
377
377
private _getCellTemplatesForRow ( rowDef : CdkRowDef ) : CdkCellDef [ ] {
378
378
if ( ! rowDef . columns ) { return [ ] ; }
379
379
return rowDef . columns . map ( columnId => {
380
- const column = this . _columnDefinitionsMap . get ( columnId ) ;
380
+ const column = this . _columnDefinitionsByName . get ( columnId ) ;
381
381
382
382
if ( ! column ) {
383
383
throw getTableUnknownColumnError ( columnId ) ;
0 commit comments