6
6
* found in the LICENSE file at https://angular.io/license
7
7
*/
8
8
9
- import { ChangeDetectionStrategy , Component , ViewEncapsulation } from '@angular/core' ;
9
+ import { ChangeDetectionStrategy , Component , OnInit , ViewEncapsulation } from '@angular/core' ;
10
10
import { CDK_TABLE_TEMPLATE , CdkTable } from '@angular/cdk/table' ;
11
11
import { BooleanInput } from '@angular/cdk/coercion' ;
12
12
@@ -16,17 +16,24 @@ import {BooleanInput} from '@angular/cdk/coercion';
16
16
template : CDK_TABLE_TEMPLATE ,
17
17
styleUrls : [ 'table.css' ] ,
18
18
host : {
19
- 'class' : 'mat-mdc-table' ,
19
+ 'class' : 'mat-mdc-table mdc-data-table__table ' ,
20
20
} ,
21
21
providers : [ { provide : CdkTable , useExisting : MatTable } ] ,
22
22
encapsulation : ViewEncapsulation . None ,
23
23
// See note on CdkTable for explanation on why this uses the default change detection strategy.
24
24
// tslint:disable-next-line:validate-decorators
25
25
changeDetection : ChangeDetectionStrategy . Default ,
26
26
} )
27
- export class MatTable < T > extends CdkTable < T > {
27
+ export class MatTable < T > extends CdkTable < T > implements OnInit {
28
28
/** Overrides the sticky CSS class set by the `CdkTable`. */
29
- protected stickyCssClass = 'mat-table-sticky' ;
29
+ protected stickyCssClass = 'mat-mdc- table-sticky' ;
30
30
31
31
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
+ }
32
39
}
0 commit comments