Skip to content

Commit 2c21531

Browse files
committed
review
1 parent 62e012d commit 2c21531

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() {
@@ -196,21 +196,21 @@ export class CdkTable<T> implements CollectionViewer {
196196
}
197197

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

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

362362
if (!column) {
363363
throw getTableUnknownColumnError(columnId);
@@ -374,7 +374,7 @@ export class CdkTable<T> implements CollectionViewer {
374374
private _getCellTemplatesForRow(rowDef: CdkRowDef): CdkCellDef[] {
375375
if (!rowDef.columns) { return []; }
376376
return rowDef.columns.map(columnId => {
377-
const column = this._columnDefinitionsMap.get(columnId);
377+
const column = this._columnDefinitionsByName.get(columnId);
378378

379379
if (!column) {
380380
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)