Revert "fix: workaround for es2015 inheritance not always working (#13834)" (#13868)

This reverts commit a22a9fa3d7.

This change caused a new issue where Closure Compiler was not able to do
dead-code elimination due to the function call with unknown side
effects.
This commit is contained in:
Jeremy Elbourn
2018-10-30 12:55:38 -07:00
committed by GitHub
parent 7cfa0c544c
commit f2c7205d66
15 changed files with 23 additions and 51 deletions
+1
View File
@@ -4,6 +4,7 @@
### Bug Fixes
* **build:** material not working with ES2015 ([#13709](https://github.com/angular/material2/issues/13709)) ([e9103a6](https://github.com/angular/material2/commit/e9103a6)), closes [#12760](https://github.com/angular/material2/issues/12760) [#13695](https://github.com/angular/material2/issues/13695)
* **button-toggle:** webkit tap highlight conflicting with ripples ([#13721](https://github.com/angular/material2/issues/13721)) ([abd0278](https://github.com/angular/material2/commit/abd0278))
* **cdk-platform:** pass `{}` to `@NgModule` since passing nothing breaks ([#13792](https://github.com/angular/material2/issues/13792)) ([5abb644](https://github.com/angular/material2/commit/5abb644))
* **checkbox:** disabled property not being coerced ([#13755](https://github.com/angular/material2/issues/13755)) ([cee8c65](https://github.com/angular/material2/commit/cee8c65)), closes [#13739](https://github.com/angular/material2/issues/13739)
@@ -1,21 +0,0 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import {Type} from '@angular/core';
/**
* Workaround for https://github.com/angular/material2/issues/12760. In order to work around
* the issue where classes which extend external classes do not have the proper metadata in
* ES2015, we just manually inherit the metadata for the constructor parameters.
* TODO(devversion): check if we can remove the workaround after ivy landed.
*/
export function _inheritCtorParametersMetadata(target: Type<any>, base: Type<any>) {
(target as any)['ctorParameters'] = () => {
const baseParameters = (base as any)['ctorParameters'];
return (typeof baseParameters === 'function' ? baseParameters() : baseParameters) || [];
};
}
-1
View File
@@ -20,4 +20,3 @@ export * from './selection/index';
// TODO: don't have this
export * from './testing/month-constants';
export * from './constructor-metadata-inherit';
+2 -2
View File
@@ -8,7 +8,6 @@
import {CdkTextareaAutosize} from '@angular/cdk/text-field';
import {Directive, Input} from '@angular/core';
import {_inheritCtorParametersMetadata} from '@angular/material/core';
/**
* Directive to automatically resize a textarea to fit its content.
@@ -46,4 +45,5 @@ export class MatTextareaAutosize extends CdkTextareaAutosize {
}
// TODO(devversion): workaround for https://github.com/angular/material2/issues/12760
_inheritCtorParametersMetadata(MatTextareaAutosize, CdkTextareaAutosize);
(MatTextareaAutosize as any)['ctorParameters'] = () =>
(CdkTextareaAutosize as any)['ctorParameters'];
+1 -2
View File
@@ -8,7 +8,6 @@
import {Directive} from '@angular/core';
import {CdkStepLabel} from '@angular/cdk/stepper';
import {_inheritCtorParametersMetadata} from '@angular/material/core';
@Directive({
selector: '[matStepLabel]',
@@ -16,4 +15,4 @@ import {_inheritCtorParametersMetadata} from '@angular/material/core';
export class MatStepLabel extends CdkStepLabel {}
// TODO(devversion): workaround for https://github.com/angular/material2/issues/12760
_inheritCtorParametersMetadata(MatStepLabel, CdkStepLabel);
(MatStepLabel as any)['ctorParameters'] = () => (CdkStepLabel as any)['ctorParameters'];
+3 -3
View File
@@ -9,7 +9,6 @@
import {Directive} from '@angular/core';
import {CdkStepper, CdkStepperNext, CdkStepperPrevious} from '@angular/cdk/stepper';
import {MatStepper} from './stepper';
import {_inheritCtorParametersMetadata} from '@angular/material/core';
/** Button that moves to the next step in a stepper workflow. */
@Directive({
@@ -36,5 +35,6 @@ export class MatStepperNext extends CdkStepperNext {}
export class MatStepperPrevious extends CdkStepperPrevious {}
// TODO(devversion): workaround for https://github.com/angular/material2/issues/12760
_inheritCtorParametersMetadata(MatStepperNext, CdkStepperNext);
_inheritCtorParametersMetadata(MatStepperPrevious, CdkStepperPrevious);
(MatStepperNext as any)['ctorParameters'] = () => (CdkStepperNext as any)['ctorParameters'];
(MatStepperPrevious as any)['ctorParameters'] = () =>
(CdkStepperPrevious as any)['ctorParameters'];
+2 -2
View File
@@ -38,7 +38,7 @@ import {
} from '@angular/core';
import {FormControl, FormGroupDirective, NgForm} from '@angular/forms';
import {DOCUMENT} from '@angular/common';
import {_inheritCtorParametersMetadata, ErrorStateMatcher} from '@angular/material/core';
import {ErrorStateMatcher} from '@angular/material/core';
import {Subject} from 'rxjs';
import {takeUntil, distinctUntilChanged} from 'rxjs/operators';
@@ -124,7 +124,7 @@ export class MatStepper extends CdkStepper implements AfterContentInit {
}
// TODO(devversion): workaround for https://github.com/angular/material2/issues/12760
_inheritCtorParametersMetadata(MatStepper, CdkStepper);
(MatStepper as any)['ctorParameters'] = () => (CdkStepper as any)['ctorParameters'];
@Component({
moduleId: module.id,
+4 -4
View File
@@ -14,7 +14,6 @@ import {
CdkHeaderCell,
CdkHeaderCellDef,
} from '@angular/cdk/table';
import {_inheritCtorParametersMetadata} from '@angular/material/core';
/**
* Cell definition for the mat-table.
@@ -47,9 +46,10 @@ export class MatHeaderCellDef extends CdkHeaderCellDef {}
export class MatFooterCellDef extends CdkFooterCellDef {}
// TODO(devversion): workaround for https://github.com/angular/material2/issues/12760
_inheritCtorParametersMetadata(MatCellDef, CdkCellDef);
_inheritCtorParametersMetadata(MatHeaderCellDef, CdkHeaderCellDef);
_inheritCtorParametersMetadata(MatFooterCellDef, CdkFooterCellDef);
(MatCellDef as any)['ctorParameters'] = () => (CdkCellDef as any)['ctorParameters'];
(MatHeaderCellDef as any)['ctorParameters'] = () => (CdkHeaderCellDef as any)['ctorParameters'];
(MatFooterCellDef as any)['ctorParameters'] = () => (MatFooterCellDef as any)['ctorParameters'];
/**
* Column definition for the mat-table.
* Defines a set of cells available for a table column.
+3 -4
View File
@@ -19,7 +19,6 @@ import {
CdkRow,
CdkRowDef,
} from '@angular/cdk/table';
import {_inheritCtorParametersMetadata} from '@angular/material/core';
/**
* Header row definition for the mat-table.
@@ -56,9 +55,9 @@ export class MatFooterRowDef extends CdkFooterRowDef {}
export class MatRowDef<T> extends CdkRowDef<T> {}
// TODO(devversion): workaround for https://github.com/angular/material2/issues/12760
_inheritCtorParametersMetadata(MatHeaderRowDef, CdkHeaderRowDef);
_inheritCtorParametersMetadata(MatFooterRowDef, CdkFooterRowDef);
_inheritCtorParametersMetadata(MatRowDef, CdkRowDef);
(MatHeaderRowDef as any)['ctorParameters'] = () => (CdkHeaderRowDef as any)['ctorParameters'];
(MatFooterRowDef as any)['ctorParameters'] = () => (CdkFooterRowDef as any)['ctorParameters'];
(MatRowDef as any)['ctorParameters'] = () => (CdkRowDef as any)['ctorParameters'];
/** Footer template container that contains the cell outlet. Adds the right class and role. */
@Component({
+1 -2
View File
@@ -8,7 +8,6 @@
import {CDK_TABLE_TEMPLATE, CdkTable} from '@angular/cdk/table';
import {ChangeDetectionStrategy, Component, ViewEncapsulation} from '@angular/core';
import {_inheritCtorParametersMetadata} from '@angular/material/core';
/**
* Wrapper for the CdkTable with Material design styles.
@@ -31,4 +30,4 @@ export class MatTable<T> extends CdkTable<T> {
}
// TODO(devversion): workaround for https://github.com/angular/material2/issues/12760
_inheritCtorParametersMetadata(MatTable, CdkTable);
(MatTable as any)['ctorParameters'] = () => (CdkTable as any)['ctorParameters'];
+1 -2
View File
@@ -8,7 +8,6 @@
import {Directive} from '@angular/core';
import {CdkPortal} from '@angular/cdk/portal';
import {_inheritCtorParametersMetadata} from '@angular/material/core';
/** Used to flag tab labels for use with the portal directive */
@Directive({
@@ -17,4 +16,4 @@ import {_inheritCtorParametersMetadata} from '@angular/material/core';
export class MatTabLabel extends CdkPortal {}
// TODO(devversion): workaround for https://github.com/angular/material2/issues/12760
_inheritCtorParametersMetadata(MatTabLabel, CdkPortal);
(MatTabLabel as any)['ctorParameters'] = () => (CdkPortal as any)['ctorParameters'];
+1 -2
View File
@@ -19,7 +19,6 @@ import {
QueryList,
} from '@angular/core';
import {
_inheritCtorParametersMetadata,
CanDisable, CanDisableCtor,
HasTabIndex,
HasTabIndexCtor,
@@ -78,7 +77,7 @@ export class MatTreeNodeDef<T> extends CdkTreeNodeDef<T> {
}
// TODO(devversion): workaround for https://github.com/angular/material2/issues/12760
_inheritCtorParametersMetadata(MatTreeNodeDef, CdkTreeNodeDef);
(MatTreeNodeDef as any)['ctorParameters'] = () => (CdkTreeNodeDef as any)['ctorParameters'];
/**
* Wrapper for the CdkTree nested node with Material design styles.
+2 -2
View File
@@ -7,7 +7,6 @@
*/
import {CdkTreeNodePadding} from '@angular/cdk/tree';
import {Directive, Input} from '@angular/core';
import {_inheritCtorParametersMetadata} from '@angular/material/core';
/**
* Wrapper for the CdkTree padding with Material design styles.
@@ -26,4 +25,5 @@ export class MatTreeNodePadding<T> extends CdkTreeNodePadding<T> {
}
// TODO(devversion): workaround for https://github.com/angular/material2/issues/12760
_inheritCtorParametersMetadata(MatTreeNodePadding, CdkTreeNodePadding);
(MatTreeNodePadding as any)['ctorParameters'] = () =>
(CdkTreeNodePadding as any)['ctorParameters'];
+1 -2
View File
@@ -8,7 +8,6 @@
import {CdkTreeNodeToggle} from '@angular/cdk/tree';
import {Directive, Input} from '@angular/core';
import {_inheritCtorParametersMetadata} from '@angular/material/core';
/**
* Wrapper for the CdkTree's toggle with Material design styles.
@@ -25,4 +24,4 @@ export class MatTreeNodeToggle<T> extends CdkTreeNodeToggle<T> {
}
// TODO(devversion): workaround for https://github.com/angular/material2/issues/12760
_inheritCtorParametersMetadata(MatTreeNodeToggle, CdkTreeNodeToggle);
(MatTreeNodeToggle as any)['ctorParameters'] = () => (CdkTreeNodeToggle as any)['ctorParameters'];
+1 -2
View File
@@ -9,7 +9,6 @@
import {CdkTree} from '@angular/cdk/tree';
import {ChangeDetectionStrategy, Component, ViewChild, ViewEncapsulation} from '@angular/core';
import {MatTreeNodeOutlet} from './outlet';
import {_inheritCtorParametersMetadata} from '@angular/material/core';
/**
* Wrapper for the CdkTable with Material design styles.
@@ -34,4 +33,4 @@ export class MatTree<T> extends CdkTree<T> {
}
// TODO(devversion): workaround for https://github.com/angular/material2/issues/12760
_inheritCtorParametersMetadata(MatTree, CdkTree);
(MatTree as any)['ctorParameters'] = () => (CdkTree as any)['ctorParameters'];