@@ -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 ( ) {
@@ -196,21 +196,21 @@ export class CdkTable<T> implements CollectionViewer {
196
196
}
197
197
198
198
/** Update the map containing the content's column definitions. */
199
- private _refreshColumnDefinitionsMap ( ) {
200
- this . _columnDefinitionsMap . clear ( ) ;
199
+ private _cacheColumnDefinitionsByName ( ) {
200
+ this . _columnDefinitionsByName . clear ( ) ;
201
201
this . _columnDefinitions . forEach ( columnDef => {
202
- if ( this . _columnDefinitionsMap . has ( columnDef . name ) ) {
202
+ if ( this . _columnDefinitionsByName . has ( columnDef . name ) ) {
203
203
throw getTableDuplicateColumnNameError ( columnDef . name ) ;
204
204
}
205
- this . _columnDefinitionsMap . set ( columnDef . name , columnDef ) ;
205
+ this . _columnDefinitionsByName . set ( columnDef . name , columnDef ) ;
206
206
} ) ;
207
207
}
208
208
209
209
/**
210
210
* Check if the header or rows have changed what columns they want to display. If there is a diff,
211
211
* then re-render that section.
212
212
*/
213
- private _checkColumnsChange ( ) {
213
+ private _renderUpdatedColumns ( ) {
214
214
// Re-render the rows when the row definition columns change.
215
215
this . _rowDefinitions . forEach ( def => {
216
216
if ( ! ! def . getColumnsDiff ( ) ) {
@@ -357,7 +357,7 @@ export class CdkTable<T> implements CollectionViewer {
357
357
private _getHeaderCellTemplatesForRow ( headerDef : CdkHeaderRowDef ) : CdkHeaderCellDef [ ] {
358
358
if ( ! headerDef . columns ) { return [ ] ; }
359
359
return headerDef . columns . map ( columnId => {
360
- const column = this . _columnDefinitionsMap . get ( columnId ) ;
360
+ const column = this . _columnDefinitionsByName . get ( columnId ) ;
361
361
362
362
if ( ! column ) {
363
363
throw getTableUnknownColumnError ( columnId ) ;
@@ -374,7 +374,7 @@ export class CdkTable<T> implements CollectionViewer {
374
374
private _getCellTemplatesForRow ( rowDef : CdkRowDef ) : CdkCellDef [ ] {
375
375
if ( ! rowDef . columns ) { return [ ] ; }
376
376
return rowDef . columns . map ( columnId => {
377
- const column = this . _columnDefinitionsMap . get ( columnId ) ;
377
+ const column = this . _columnDefinitionsByName . get ( columnId ) ;
378
378
379
379
if ( ! column ) {
380
380
throw getTableUnknownColumnError ( columnId ) ;
0 commit comments