Skip to content

Commit

Permalink
rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewseguin committed Jul 27, 2017
1 parent 40dad50 commit 9beeaaa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 28 deletions.
2 changes: 1 addition & 1 deletion src/cdk/table/table.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {CdkTableModule} from './index';
import {map} from 'rxjs/operator/map';
import {getTableDuplicateColumnNameError, getTableUnknownColumnError} from './table-errors';

describe('CdkTable', () => {
fdescribe('CdkTable', () => {
let fixture: ComponentFixture<SimpleCdkTableApp>;

let component: SimpleCdkTableApp;
Expand Down
29 changes: 2 additions & 27 deletions src/cdk/table/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ export class CdkTable<T> implements CollectionViewer {

constructor(private readonly _differs: IterableDiffers,
private readonly _changeDetectorRef: ChangeDetectorRef,
private readonly _ngZone: NgZone,
elementRef: ElementRef,
renderer: Renderer2,
@Attribute('role') role: string) {
Expand All @@ -166,26 +165,13 @@ export class CdkTable<T> implements CollectionViewer {
this._dataDiffer = this._differs.find([]).create(this._trackByFn);
}

ngDoCheck() {
// After the the content and view have been initialized and checked then we can connect
// to the data source and render data rows. This cannot be done from within change detection,
// so the table must wait until the next change detection cycle before rendering.
if (this._isViewInitialized && this.dataSource && !this._renderChangeSubscription) {
this._observeRenderChanges();
}
}

ngAfterContentInit() {
this._cacheColumnDefinitionsByName();
this._columnDefinitions.changes.subscribe(() => this._cacheColumnDefinitionsByName());
}

ngAfterContentChecked() {
this._renderUpdatedColumns();
this._cacheColumnDefinitionsByName();
}

ngAfterViewInit() {
if (this.dataSource && !this._renderChangeSubscription) {
this._observeRenderChanges();
}
Expand All @@ -202,17 +188,6 @@ export class CdkTable<T> implements CollectionViewer {
}
}

ngAfterContentInit() {
// TODO(andrewseguin): Throw an error if two columns share the same name
this._columnDefinitions.forEach(columnDef => {
this._columnDefinitionsByName.set(columnDef.name, columnDef);
});

if (this.dataSource && !this._renderChangeSubscription) {
this._observeRenderChanges();
}
}


/** Update the map containing the content's column definitions. */
private _cacheColumnDefinitionsByName() {
Expand All @@ -231,8 +206,8 @@ export class CdkTable<T> implements CollectionViewer {
*/
private _renderUpdatedColumns() {
// Re-render the rows when the row definition columns change.
this._rowDefinitions.forEach(def => {
if (!!def.getColumnsDiff()) {
this._rowDefinitions.forEach(rowDefinition => {
if (!!rowDefinition.getColumnsDiff()) {
// Reset the data to an empty array so that renderRowChanges will re-render all new rows.
this._dataDiffer.diff([]);

Expand Down

0 comments on commit 9beeaaa

Please sign in to comment.