66 * found in the LICENSE file at https://angular.io/license
77 */
88
9- import { ChangeDetectionStrategy , Component , ViewEncapsulation } from '@angular/core' ;
9+ import { ChangeDetectionStrategy , Component , OnInit , ViewEncapsulation } from '@angular/core' ;
1010import { CDK_TABLE_TEMPLATE , CdkTable } from '@angular/cdk/table' ;
1111import { BooleanInput } from '@angular/cdk/coercion' ;
1212
@@ -16,17 +16,24 @@ import {BooleanInput} from '@angular/cdk/coercion';
1616 template : CDK_TABLE_TEMPLATE ,
1717 styleUrls : [ 'table.css' ] ,
1818 host : {
19- 'class' : 'mat-mdc-table' ,
19+ 'class' : 'mat-mdc-table mdc-data-table__table ' ,
2020 } ,
2121 providers : [ { provide : CdkTable , useExisting : MatTable } ] ,
2222 encapsulation : ViewEncapsulation . None ,
2323 // See note on CdkTable for explanation on why this uses the default change detection strategy.
2424 // tslint:disable-next-line:validate-decorators
2525 changeDetection : ChangeDetectionStrategy . Default ,
2626} )
27- export class MatTable < T > extends CdkTable < T > {
27+ export class MatTable < T > extends CdkTable < T > implements OnInit {
2828 /** Overrides the sticky CSS class set by the `CdkTable`. */
29- protected stickyCssClass = 'mat-table-sticky' ;
29+ protected stickyCssClass = 'mat-mdc- table-sticky' ;
3030
3131 static ngAcceptInputType_multiTemplateDataRows : BooleanInput ;
32+
33+ // After ngOnInit, the `CdkTable` has created and inserted the table sections (thead, tbody,
34+ // tfoot). MDC requires the `mdc-data-table__content` class to be added to the body.
35+ ngOnInit ( ) {
36+ super . ngOnInit ( ) ;
37+ this . _elementRef . nativeElement . querySelector ( 'tbody' ) . classList . add ( 'mdc-data-table__content' ) ;
38+ }
3239}
0 commit comments