Skip to content

Commit 597c324

Browse files
committed
fix(table): not rendering properly in es2015 apps
Fixes that the table does not render properly when used inside of a ES2015 application. This is due to an ongoing Angular issue which has been caused due to a brittle Regex check [introduced here](angular/angular#22356 (comment)) that should be replaced with a more clean approach for identifying classes that inherit metadata from another class. * angular/angular#22642 * angular/tsickle#760 Fixes #9329
1 parent b9651df commit 597c324

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

src/lib/table/cell.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,17 @@ import {
1515
CdkHeaderCellDef,
1616
} from '@angular/cdk/table';
1717

18+
/**
19+
* Workaround that ensures that dependency injection for the derived table classes properly works
20+
* within Webpack/Angular CLI projects that use ES2015. See the following links for more details:
21+
* - https://github.com/angular/angular/pull/22356#issuecomment-387756794
22+
* - https://github.com/angular/angular/pull/22642
23+
*/
24+
// TODO(devversion): Remove once Material depends on a future Angular version that includes #22642
25+
export const _CdkCellDef = CdkCellDef;
26+
export const _CdkHeaderCellDef = CdkHeaderCellDef;
27+
export const _CdkFooterCellDef = CdkFooterCellDef;
28+
1829
/**
1930
* Cell definition for the mat-table.
2031
* Captures the template of a column's data row cell as well as cell-specific properties.
@@ -23,7 +34,7 @@ import {
2334
selector: '[matCellDef]',
2435
providers: [{provide: CdkCellDef, useExisting: MatCellDef}]
2536
})
26-
export class MatCellDef extends CdkCellDef {}
37+
export class MatCellDef extends _CdkCellDef {}
2738

2839
/**
2940
* Header cell definition for the mat-table.
@@ -33,7 +44,7 @@ export class MatCellDef extends CdkCellDef {}
3344
selector: '[matHeaderCellDef]',
3445
providers: [{provide: CdkHeaderCellDef, useExisting: MatHeaderCellDef}]
3546
})
36-
export class MatHeaderCellDef extends CdkHeaderCellDef {}
47+
export class MatHeaderCellDef extends _CdkHeaderCellDef {}
3748

3849
/**
3950
* Footer cell definition for the mat-table.
@@ -43,7 +54,7 @@ export class MatHeaderCellDef extends CdkHeaderCellDef {}
4354
selector: '[matFooterCellDef]',
4455
providers: [{provide: CdkFooterCellDef, useExisting: MatFooterCellDef}]
4556
})
46-
export class MatFooterCellDef extends CdkFooterCellDef {}
57+
export class MatFooterCellDef extends _CdkFooterCellDef {}
4758

4859
/**
4960
* Column definition for the mat-table.

src/lib/table/row.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,17 @@ import {
2020
CdkRowDef,
2121
} from '@angular/cdk/table';
2222

23+
/**
24+
* Workaround that ensures that dependency injection for the derived table classes properly works
25+
* within Webpack/Angular CLI projects that use ES2015. See the following links for more details:
26+
* - https://github.com/angular/angular/pull/22356#issuecomment-387756794
27+
* - https://github.com/angular/angular/pull/22642
28+
*/
29+
// TODO(devversion): Remove once Material depends on a future Angular version that includes #22642
30+
export const _CdkHeaderRowDef = CdkHeaderRowDef;
31+
export const _CdkFooterRowDef = CdkFooterRowDef;
32+
export const _CdkRowDef = CdkRowDef;
33+
2334
/**
2435
* Header row definition for the mat-table.
2536
* Captures the header row's template and other header properties such as the columns to display.
@@ -29,7 +40,7 @@ import {
2940
providers: [{provide: CdkHeaderRowDef, useExisting: MatHeaderRowDef}],
3041
inputs: ['columns: matHeaderRowDef', 'sticky: matHeaderRowDefSticky'],
3142
})
32-
export class MatHeaderRowDef extends CdkHeaderRowDef {}
43+
export class MatHeaderRowDef extends _CdkHeaderRowDef {}
3344

3445
/**
3546
* Footer row definition for the mat-table.
@@ -40,7 +51,7 @@ export class MatHeaderRowDef extends CdkHeaderRowDef {}
4051
providers: [{provide: CdkFooterRowDef, useExisting: MatFooterRowDef}],
4152
inputs: ['columns: matFooterRowDef', 'sticky: matFooterRowDefSticky'],
4253
})
43-
export class MatFooterRowDef extends CdkFooterRowDef {}
54+
export class MatFooterRowDef extends _CdkFooterRowDef {}
4455

4556
/**
4657
* Data row definition for the mat-table.
@@ -52,7 +63,7 @@ export class MatFooterRowDef extends CdkFooterRowDef {}
5263
providers: [{provide: CdkRowDef, useExisting: MatRowDef}],
5364
inputs: ['columns: matRowDefColumns', 'when: matRowDefWhen'],
5465
})
55-
export class MatRowDef<T> extends CdkRowDef<T> {}
66+
export class MatRowDef<T> extends _CdkRowDef<T> {}
5667

5768
/** Footer template container that contains the cell outlet. Adds the right class and role. */
5869
@Component({

0 commit comments

Comments
 (0)