Skip to content

Commit 008ccc1

Browse files
committed
fix: ensure components work with ES2015 in jit mode.
Fixes that some components does not render properly when used inside of a ES2015 JIT 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 See the more detailed issue here: angular#12760 Fixes angular#9329.
1 parent b9651df commit 008ccc1

File tree

13 files changed

+65
-111
lines changed

13 files changed

+65
-111
lines changed

src/lib/expansion/expansion-panel.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ import {MatAccordion} from './accordion';
3535
import {matExpansionAnimations} from './expansion-animations';
3636
import {MatExpansionPanelContent} from './expansion-panel-content';
3737

38+
// TODO(devversion): workaround for https://github.com/angular/material2/issues/12760
39+
export const _CdkAccordionItem = CdkAccordionItem;
3840

3941
/** MatExpansionPanel's states. */
4042
export type MatExpansionPanelState = 'expanded' | 'collapsed';
@@ -70,7 +72,7 @@ let uniqueId = 0;
7072
'[class.mat-expansion-panel-spacing]': '_hasSpacing()',
7173
}
7274
})
73-
export class MatExpansionPanel extends CdkAccordionItem
75+
export class MatExpansionPanel extends _CdkAccordionItem
7476
implements AfterContentInit, OnChanges, OnDestroy {
7577
/** Whether the toggle indicator should be hidden. */
7678
@Input()

src/lib/input/autosize.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import {CdkTextareaAutosize} from '@angular/cdk/text-field';
1010
import {Directive, Input} from '@angular/core';
1111

12+
// TODO(devversion): Workaround for https://github.com/angular/material2/issues/12760
13+
export const _CdkTextareaAutosize = CdkTextareaAutosize;
1214

1315
/**
1416
* Directive to automatically resize a textarea to fit its content.
@@ -27,7 +29,7 @@ import {Directive, Input} from '@angular/core';
2729
'(input)': '_noopInputHandler()',
2830
},
2931
})
30-
export class MatTextareaAutosize extends CdkTextareaAutosize {
32+
export class MatTextareaAutosize extends _CdkTextareaAutosize {
3133
@Input()
3234
get matAutosizeMinRows(): number { return this.minRows; }
3335
set matAutosizeMinRows(value: number) { this.minRows = value; }

src/lib/stepper/step-label.ts

+5-6
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {Directive, TemplateRef} from '@angular/core';
9+
import {Directive} from '@angular/core';
1010
import {CdkStepLabel} from '@angular/cdk/stepper';
1111

12+
// TODO(devversion): workaround for https://github.com/angular/material2/issues/12760
13+
export const _CdkStepLabel = CdkStepLabel;
14+
1215
@Directive({
1316
selector: '[matStepLabel]',
1417
})
15-
export class MatStepLabel extends CdkStepLabel {
16-
constructor(template: TemplateRef<any>) {
17-
super(template);
18-
}
19-
}
18+
export class MatStepLabel extends _CdkStepLabel {}

src/lib/stepper/stepper-button.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ import {Directive} from '@angular/core';
1010
import {CdkStepper, CdkStepperNext, CdkStepperPrevious} from '@angular/cdk/stepper';
1111
import {MatStepper} from './stepper';
1212

13+
// TODO(devversion): workaround for https://github.com/angular/material2/issues/12760
14+
export const _CdkStepperNext = CdkStepperNext;
15+
export const _CdkStepperPrevious = CdkStepperPrevious;
16+
1317
/** Button that moves to the next step in a stepper workflow. */
1418
@Directive({
1519
selector: 'button[matStepperNext]',
@@ -20,7 +24,7 @@ import {MatStepper} from './stepper';
2024
inputs: ['type'],
2125
providers: [{provide: CdkStepper, useExisting: MatStepper}]
2226
})
23-
export class MatStepperNext extends CdkStepperNext {}
27+
export class MatStepperNext extends _CdkStepperNext {}
2428

2529
/** Button that moves to the previous step in a stepper workflow. */
2630
@Directive({
@@ -32,4 +36,4 @@ export class MatStepperNext extends CdkStepperNext {}
3236
inputs: ['type'],
3337
providers: [{provide: CdkStepper, useExisting: MatStepper}]
3438
})
35-
export class MatStepperPrevious extends CdkStepperPrevious {}
39+
export class MatStepperPrevious extends _CdkStepperPrevious {}

src/lib/stepper/stepper.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ import {takeUntil} from 'rxjs/operators';
3636
import {matStepperAnimations} from './stepper-animations';
3737
import {MatStepperIcon, MatStepperIconContext} from './stepper-icon';
3838

39+
// TODO(devversion): workaround for https://github.com/angular/material2/issues/12760
40+
export const _CdkStepper = CdkStepper;
3941

4042
@Component({
4143
moduleId: module.id,
@@ -72,7 +74,7 @@ export class MatStep extends CdkStep implements ErrorStateMatcher {
7274
@Directive({
7375
selector: '[matStepper]'
7476
})
75-
export class MatStepper extends CdkStepper implements AfterContentInit {
77+
export class MatStepper extends _CdkStepper implements AfterContentInit {
7678
/** The list of step headers of the steps in the stepper. */
7779
@ViewChildren(MatStepHeader) _stepHeader: QueryList<MatStepHeader>;
7880

src/lib/table/cell.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ import {
1515
CdkHeaderCellDef,
1616
} from '@angular/cdk/table';
1717

18+
// TODO(devversion): workaround for https://github.com/angular/material2/issues/12760
19+
export const _CdkCellDef = CdkCellDef;
20+
export const _CdkHeaderCellDef = CdkHeaderCellDef;
21+
export const _CdkFooterCellDef = CdkFooterCellDef;
22+
1823
/**
1924
* Cell definition for the mat-table.
2025
* Captures the template of a column's data row cell as well as cell-specific properties.
@@ -23,7 +28,7 @@ import {
2328
selector: '[matCellDef]',
2429
providers: [{provide: CdkCellDef, useExisting: MatCellDef}]
2530
})
26-
export class MatCellDef extends CdkCellDef {}
31+
export class MatCellDef extends _CdkCellDef {}
2732

2833
/**
2934
* Header cell definition for the mat-table.
@@ -33,7 +38,7 @@ export class MatCellDef extends CdkCellDef {}
3338
selector: '[matHeaderCellDef]',
3439
providers: [{provide: CdkHeaderCellDef, useExisting: MatHeaderCellDef}]
3540
})
36-
export class MatHeaderCellDef extends CdkHeaderCellDef {}
41+
export class MatHeaderCellDef extends _CdkHeaderCellDef {}
3742

3843
/**
3944
* Footer cell definition for the mat-table.
@@ -43,7 +48,7 @@ export class MatHeaderCellDef extends CdkHeaderCellDef {}
4348
selector: '[matFooterCellDef]',
4449
providers: [{provide: CdkFooterCellDef, useExisting: MatFooterCellDef}]
4550
})
46-
export class MatFooterCellDef extends CdkFooterCellDef {}
51+
export class MatFooterCellDef extends _CdkFooterCellDef {}
4752

4853
/**
4954
* Column definition for the mat-table.

src/lib/table/row.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ import {
2020
CdkRowDef,
2121
} from '@angular/cdk/table';
2222

23+
// TODO(devversion): workaround for https://github.com/angular/material2/issues/12760
24+
export const _CdkHeaderRowDef = CdkHeaderRowDef;
25+
export const _CdkFooterRowDef = CdkFooterRowDef;
26+
export const _CdkRowDef = CdkRowDef;
27+
2328
/**
2429
* Header row definition for the mat-table.
2530
* Captures the header row's template and other header properties such as the columns to display.
@@ -29,7 +34,7 @@ import {
2934
providers: [{provide: CdkHeaderRowDef, useExisting: MatHeaderRowDef}],
3035
inputs: ['columns: matHeaderRowDef', 'sticky: matHeaderRowDefSticky'],
3136
})
32-
export class MatHeaderRowDef extends CdkHeaderRowDef {}
37+
export class MatHeaderRowDef extends _CdkHeaderRowDef {}
3338

3439
/**
3540
* Footer row definition for the mat-table.
@@ -40,7 +45,7 @@ export class MatHeaderRowDef extends CdkHeaderRowDef {}
4045
providers: [{provide: CdkFooterRowDef, useExisting: MatFooterRowDef}],
4146
inputs: ['columns: matFooterRowDef', 'sticky: matFooterRowDefSticky'],
4247
})
43-
export class MatFooterRowDef extends CdkFooterRowDef {}
48+
export class MatFooterRowDef extends _CdkFooterRowDef {}
4449

4550
/**
4651
* Data row definition for the mat-table.
@@ -52,7 +57,7 @@ export class MatFooterRowDef extends CdkFooterRowDef {}
5257
providers: [{provide: CdkRowDef, useExisting: MatRowDef}],
5358
inputs: ['columns: matRowDefColumns', 'when: matRowDefWhen'],
5459
})
55-
export class MatRowDef<T> extends CdkRowDef<T> {}
60+
export class MatRowDef<T> extends _CdkRowDef<T> {}
5661

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

src/lib/table/table.ts

+5-25
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,11 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {
10-
Attribute,
11-
ChangeDetectionStrategy,
12-
ChangeDetectorRef,
13-
Component,
14-
ElementRef,
15-
IterableDiffers,
16-
Optional,
17-
ViewEncapsulation
18-
} from '@angular/core';
199
import {CDK_TABLE_TEMPLATE, CdkTable} from '@angular/cdk/table';
20-
import {Directionality} from '@angular/cdk/bidi';
10+
import {ChangeDetectionStrategy, Component, ViewEncapsulation} from '@angular/core';
11+
12+
// TODO(devversion): workaround for https://github.com/angular/material2/issues/12760
13+
export const _CdkTable = CdkTable;
2114

2215
/**
2316
* Wrapper for the CdkTable with Material design styles.
@@ -34,20 +27,7 @@ import {Directionality} from '@angular/cdk/bidi';
3427
encapsulation: ViewEncapsulation.None,
3528
changeDetection: ChangeDetectionStrategy.OnPush,
3629
})
37-
export class MatTable<T> extends CdkTable<T> {
30+
export class MatTable<T> extends _CdkTable<T> {
3831
/** Overrides the sticky CSS class set by the `CdkTable`. */
3932
protected stickyCssClass = 'mat-table-sticky';
40-
41-
// TODO(andrewseguin): Remove this explicitly set constructor when the compiler knows how to
42-
// properly build the es6 version of the class. Currently sets ctorParameters to empty due to a
43-
// fixed bug.
44-
// https://github.com/angular/tsickle/pull/760 - tsickle PR that fixed this
45-
// https://github.com/angular/angular/pull/23531 - updates compiler-cli to fixed version
46-
constructor(protected _differs: IterableDiffers,
47-
protected _changeDetectorRef: ChangeDetectorRef,
48-
protected _elementRef: ElementRef,
49-
@Attribute('role') role: string,
50-
@Optional() protected readonly _dir: Directionality) {
51-
super(_differs, _changeDetectorRef, _elementRef, role, _dir);
52-
}
5333
}

src/lib/tabs/tab-label.ts

+5-6
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {Directive, TemplateRef, ViewContainerRef} from '@angular/core';
9+
import {Directive} from '@angular/core';
1010
import {CdkPortal} from '@angular/cdk/portal';
1111

12+
// TODO(devversion): Workaround for https://github.com/angular/material2/issues/12760
13+
export const _CdkPortal = CdkPortal;
14+
1215
/** Used to flag tab labels for use with the portal directive */
1316
@Directive({
1417
selector: '[mat-tab-label], [matTabLabel]',
1518
})
16-
export class MatTabLabel extends CdkPortal {
17-
constructor(templateRef: TemplateRef<any>, viewContainerRef: ViewContainerRef) {
18-
super(templateRef, viewContainerRef);
19-
}
20-
}
19+
export class MatTabLabel extends _CdkPortal {}

src/lib/tree/node.ts

+4-17
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,7 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {
10-
CdkNestedTreeNode,
11-
CdkTree,
12-
CdkTreeNode,
13-
CdkTreeNodeDef,
14-
} from '@angular/cdk/tree';
9+
import {CdkNestedTreeNode, CdkTree, CdkTreeNode, CdkTreeNodeDef} from '@angular/cdk/tree';
1510
import {
1611
AfterContentInit,
1712
Attribute,
@@ -22,11 +17,12 @@ import {
2217
IterableDiffers,
2318
OnDestroy,
2419
QueryList,
25-
TemplateRef,
2620
} from '@angular/core';
2721
import {CanDisable, HasTabIndex, mixinDisabled, mixinTabIndex} from '@angular/material/core';
2822
import {MatTreeNodeOutlet} from './outlet';
2923

24+
// TODO(devversion): workaround for https://github.com/angular/material2/issues/12760
25+
export const _CdkTreeNodeDef = CdkTreeNodeDef;
3026

3127
export const _MatTreeNodeMixinBase = mixinTabIndex(mixinDisabled(CdkTreeNode));
3228
export const _MatNestedTreeNodeMixinBase = mixinTabIndex(mixinDisabled(CdkNestedTreeNode));
@@ -69,17 +65,8 @@ export class MatTreeNode<T> extends _MatTreeNodeMixinBase<T>
6965
],
7066
providers: [{provide: CdkTreeNodeDef, useExisting: MatTreeNodeDef}]
7167
})
72-
export class MatTreeNodeDef<T> extends CdkTreeNodeDef<T> {
68+
export class MatTreeNodeDef<T> extends _CdkTreeNodeDef<T> {
7369
@Input('matTreeNode') data: T;
74-
75-
// TODO(andrewseguin): Remove this explicitly set constructor when the compiler knows how to
76-
// properly build the es6 version of the class. Currently sets ctorParameters to empty due to a
77-
// fixed bug.
78-
// https://github.com/angular/tsickle/pull/760 - tsickle PR that fixed this
79-
// https://github.com/angular/angular/pull/23531 - updates compiler-cli to fixed version
80-
constructor(template: TemplateRef<any>) {
81-
super(template);
82-
}
8370
}
8471

8572
/**

src/lib/tree/padding.ts

+5-17
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
* Use of this source code is governed by an MIT-style license that can be
66
* found in the LICENSE file at https://angular.io/license
77
*/
8-
import {CdkTreeNodePadding, CdkTreeNode, CdkTree} from '@angular/cdk/tree';
9-
import {Directionality} from '@angular/cdk/bidi';
10-
import {Directive, Input, Optional, Renderer2, ElementRef} from '@angular/core';
8+
import {CdkTreeNodePadding} from '@angular/cdk/tree';
9+
import {Directive, Input} from '@angular/core';
1110

11+
// TODO(devversion): workaround for https://github.com/angular/material2/issues/12760
12+
export const _CdkTreeNodePadding = CdkTreeNodePadding;
1213

1314
/**
1415
* Wrapper for the CdkTree padding with Material design styles.
@@ -17,24 +18,11 @@ import {Directive, Input, Optional, Renderer2, ElementRef} from '@angular/core';
1718
selector: '[matTreeNodePadding]',
1819
providers: [{provide: CdkTreeNodePadding, useExisting: MatTreeNodePadding}]
1920
})
20-
export class MatTreeNodePadding<T> extends CdkTreeNodePadding<T> {
21+
export class MatTreeNodePadding<T> extends _CdkTreeNodePadding<T> {
2122

2223
/** The level of depth of the tree node. The padding will be `level * indent` pixels. */
2324
@Input('matTreeNodePadding') level: number;
2425

2526
/** The indent for each level. Default number 40px from material design menu sub-menu spec. */
2627
@Input('matTreeNodePaddingIndent') indent: number;
27-
28-
// TODO(andrewseguin): Remove this explicitly set constructor when the compiler knows how to
29-
// properly build the es6 version of the class. Currently sets ctorParameters to empty due to a
30-
// fixed bug.
31-
// https://github.com/angular/tsickle/pull/760 - tsickle PR that fixed this
32-
// https://github.com/angular/angular/pull/23531 - updates compiler-cli to fixed version
33-
constructor(_treeNode: CdkTreeNode<T>,
34-
_tree: CdkTree<T>,
35-
_renderer: Renderer2,
36-
_element: ElementRef,
37-
@Optional() _dir: Directionality) {
38-
super(_treeNode, _tree, _renderer, _element, _dir);
39-
}
4028
}

src/lib/tree/toggle.ts

+5-11
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9+
import {CdkTreeNodeToggle} from '@angular/cdk/tree';
910
import {Directive, Input} from '@angular/core';
10-
import {CdkTreeNodeToggle, CdkTree, CdkTreeNode} from '@angular/cdk/tree';
11+
12+
// TODO(devversion): workaround for https://github.com/angular/material2/issues/12760
13+
export const _CdkTreeNodeToggle = CdkTreeNodeToggle;
1114

1215
/**
1316
* Wrapper for the CdkTree's toggle with Material design styles.
@@ -19,15 +22,6 @@ import {CdkTreeNodeToggle, CdkTree, CdkTreeNode} from '@angular/cdk/tree';
1922
},
2023
providers: [{provide: CdkTreeNodeToggle, useExisting: MatTreeNodeToggle}]
2124
})
22-
export class MatTreeNodeToggle<T> extends CdkTreeNodeToggle<T> {
25+
export class MatTreeNodeToggle<T> extends _CdkTreeNodeToggle<T> {
2326
@Input('matTreeNodeToggleRecursive') recursive: boolean = false;
24-
25-
// TODO(andrewseguin): Remove this explicitly set constructor when the compiler knows how to
26-
// properly build the es6 version of the class. Currently sets ctorParameters to empty due to a
27-
// fixed bug.
28-
// https://github.com/angular/tsickle/pull/760 - tsickle PR that fixed this
29-
// https://github.com/angular/angular/pull/23531 - updates compiler-cli to fixed version
30-
constructor(_tree: CdkTree<T>, _treeNode: CdkTreeNode<T>) {
31-
super(_tree, _treeNode);
32-
}
3327
}

0 commit comments

Comments
 (0)