Skip to content

Commit 52691d3

Browse files
committed
review
1 parent 753401a commit 52691d3

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

src/cdk/table/table.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export class CdkTable<T> implements CollectionViewer {
9191
private _renderChangeSubscription: Subscription;
9292

9393
/** 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>();
9595

9696
/** Differ used to find the changes in the data provided by the data source. */
9797
private _dataDiffer: IterableDiffer<T>;
@@ -169,12 +169,12 @@ export class CdkTable<T> implements CollectionViewer {
169169

170170
ngAfterContentInit() {
171171
// 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());
174174
}
175175

176176
ngAfterContentChecked() {
177-
this._checkColumnsChange();
177+
this._renderUpdatedColumns();
178178
}
179179

180180
ngAfterViewInit() {
@@ -199,21 +199,21 @@ export class CdkTable<T> implements CollectionViewer {
199199
}
200200

201201
/** Update the map containing the content's column definitions. */
202-
private _refreshColumnDefinitionsMap() {
203-
this._columnDefinitionsMap.clear();
202+
private _cacheColumnDefinitionsByName() {
203+
this._columnDefinitionsByName.clear();
204204
this._columnDefinitions.forEach(columnDef => {
205-
if (this._columnDefinitionsMap.has(columnDef.name)) {
205+
if (this._columnDefinitionsByName.has(columnDef.name)) {
206206
throw getTableDuplicateColumnNameError(columnDef.name);
207207
}
208-
this._columnDefinitionsMap.set(columnDef.name, columnDef);
208+
this._columnDefinitionsByName.set(columnDef.name, columnDef);
209209
});
210210
}
211211

212212
/**
213213
* Check if the header or rows have changed what columns they want to display. If there is a diff,
214214
* then re-render that section.
215215
*/
216-
private _checkColumnsChange() {
216+
private _renderUpdatedColumns() {
217217
// Re-render the rows when the row definition columns change.
218218
this._rowDefinitions.forEach(def => {
219219
if (!!def.getColumnsDiff()) {
@@ -360,7 +360,7 @@ export class CdkTable<T> implements CollectionViewer {
360360
private _getHeaderCellTemplatesForRow(headerDef: CdkHeaderRowDef): CdkHeaderCellDef[] {
361361
if (!headerDef.columns) { return []; }
362362
return headerDef.columns.map(columnId => {
363-
const column = this._columnDefinitionsMap.get(columnId);
363+
const column = this._columnDefinitionsByName.get(columnId);
364364

365365
if (!column) {
366366
throw getTableUnknownColumnError(columnId);
@@ -377,7 +377,7 @@ export class CdkTable<T> implements CollectionViewer {
377377
private _getCellTemplatesForRow(rowDef: CdkRowDef): CdkCellDef[] {
378378
if (!rowDef.columns) { return []; }
379379
return rowDef.columns.map(columnId => {
380-
const column = this._columnDefinitionsMap.get(columnId);
380+
const column = this._columnDefinitionsByName.get(columnId);
381381

382382
if (!column) {
383383
throw getTableUnknownColumnError(columnId);

src/demo-app/table/table-demo.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
</div>
2020
</div>
2121

22-
<md-card>
22+
<md-card class="demo-table-card">
2323
<h3>
2424
CdkTable With Dynamic Column Def
2525
<div>
@@ -47,7 +47,7 @@ <h3>
4747
</cdk-table>
4848
</md-card>
4949

50-
<md-card>
50+
<md-card class="demo-table-card">
5151
<h3>CdkTable Example</h3>
5252

5353
<div class="demo-highlighter">

src/demo-app/table/table-demo.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
.demo-row-highlight-even { background: #ff0099; }
2323
.demo-row-highlight-odd { background: #83f52c; }
2424

25-
.mat-card {
25+
.demo-table-card {
2626
margin: 24px 0;
2727
max-height: 200px;
2828
overflow: auto;

0 commit comments

Comments
 (0)