Skip to content

Commit 440b1b7

Browse files
devversionmmalerba
authored andcommitted
refactor: remove abstract directive selector workaround (#17476)
Since we updated the minimum required Angular version, and updated to Angular v9.0.0-0, we can remove the workaround for abstract directives. Previously we wanted to keep them with a selector regardless of the installed version, because we thought that we want to support ^8.0.0 of Angular.
1 parent 6b7f091 commit 440b1b7

File tree

18 files changed

+47
-112
lines changed

18 files changed

+47
-112
lines changed

src/cdk-experimental/popover-edit/popover-edit.spec.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,7 @@ interface PeriodicElement {
6161
weight: number;
6262
}
6363

64-
@Directive({
65-
// TODO(devversion): this selector can be removed when we update to Angular 9.0.
66-
selector: 'do-not-use-abstract-cdk-popover-edit-base-test-component'
67-
})
64+
@Directive()
6865
abstract class BaseTestComponent {
6966
@ViewChild('table') table: ElementRef;
7067

src/material-experimental/mdc-button/button-base.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,7 @@ export const _MatButtonBaseMixin: CanDisableRippleCtor&CanDisableCtor&CanColorCt
7979
typeof MatButtonMixinCore = mixinColor(mixinDisabled(mixinDisableRipple(MatButtonMixinCore)));
8080

8181
/** Base class for all buttons. */
82-
@Directive({
83-
// TODO(devversion): this selector can be removed when we update to Angular 9.0.
84-
selector: 'do-not-use-abstract-mat-button-base'
85-
})
82+
@Directive()
8683
export class MatButtonBase extends _MatButtonBaseMixin implements CanDisable, CanColor,
8784
CanDisableRipple {
8885
/** The ripple animation configuration to use for the buttons. */
@@ -154,10 +151,7 @@ export const MAT_ANCHOR_HOST = {
154151
/**
155152
* Anchor button base.
156153
*/
157-
@Directive({
158-
// TODO(devversion): this selector can be removed when we update to Angular 9.0.
159-
selector: 'do-not-use-abstract-mat-anchor-base'
160-
})
154+
@Directive()
161155
export class MatAnchorBase extends MatButtonBase {
162156
tabIndex: number;
163157

src/material-experimental/mdc-button/module.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {CommonModule} from '@angular/common';
1010
import {NgModule} from '@angular/core';
1111
import {MatCommonModule, MatRippleModule} from '@angular/material/core';
1212
import {MatAnchor, MatButton} from './button';
13-
import {MatAnchorBase, MatButtonBase} from './button-base';
1413
import {MatFabAnchor, MatFabButton} from './fab';
1514
import {MatIconAnchor, MatIconButton} from './icon-button';
1615

@@ -32,10 +31,6 @@ import {MatIconAnchor, MatIconButton} from './icon-button';
3231
MatIconButton,
3332
MatFabAnchor,
3433
MatFabButton,
35-
// TODO(devversion): remove when `MatButtonBase` becomes a selectorless Directive.
36-
MatButtonBase,
37-
// TODO(devversion): remove when `MatAnchorBase` becomes a selectorless Directive.
38-
MatAnchorBase,
3934
],
4035
})
4136
export class MatButtonModule {

src/material-experimental/popover-edit/popover-edit.spec.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,7 @@ interface PeriodicElement {
5959
weight: number;
6060
}
6161

62-
@Directive({
63-
// TODO(devversion): this selector can be removed when we update to Angular 9.0.
64-
selector: 'do-not-use-abstract-mat-popover-edit-base-test-component'
65-
})
62+
@Directive()
6663
abstract class BaseTestComponent {
6764
@ViewChild('table') table: ElementRef;
6865

src/material/form-field/form-field-control.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,7 @@ import {Directive} from '@angular/core';
1212

1313

1414
/** An interface which allows a control to work inside of a `MatFormField`. */
15-
@Directive({
16-
// The @Directive with selector is required here because we're still running a lot of things
17-
// against ViewEngine where directives without selectors are not allowed.
18-
// TODO(crisbeto): convert to a selectorless Directive after we switch to Ivy.
19-
selector: 'do-not-use-abstract-mat-form-field-control',
20-
})
15+
@Directive()
2116
export abstract class MatFormFieldControl<T> {
2217
/** The value of the control. */
2318
value: T | null;

src/material/form-field/form-field-module.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ import {MatLabel} from './label';
1616
import {MatPlaceholder} from './placeholder';
1717
import {MatPrefix} from './prefix';
1818
import {MatSuffix} from './suffix';
19-
import {MatFormFieldControl} from './form-field-control';
20-
2119

2220
@NgModule({
2321
declarations: [
@@ -28,10 +26,6 @@ import {MatFormFieldControl} from './form-field-control';
2826
MatPlaceholder,
2927
MatPrefix,
3028
MatSuffix,
31-
32-
// TODO(crisbeto): can be removed once `MatFormFieldControl`
33-
// is turned into a selector-less directive.
34-
MatFormFieldControl as any,
3529
],
3630
imports: [
3731
CommonModule,

src/material/menu/menu-module.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,10 @@ import {OverlayModule} from '@angular/cdk/overlay';
1010
import {CommonModule} from '@angular/common';
1111
import {NgModule} from '@angular/core';
1212
import {MatCommonModule, MatRippleModule} from '@angular/material/core';
13+
import {_MatMenu} from './menu';
1314
import {MatMenuContent} from './menu-content';
14-
import {_MatMenu, _MatMenuBase, MatMenu} from './menu';
1515
import {MatMenuItem} from './menu-item';
16-
import {
17-
MatMenuTrigger,
18-
MAT_MENU_SCROLL_STRATEGY_FACTORY_PROVIDER,
19-
} from './menu-trigger';
16+
import {MAT_MENU_SCROLL_STRATEGY_FACTORY_PROVIDER, MatMenuTrigger} from './menu-trigger';
2017

2118
/**
2219
* Used by both the current `MatMenuModule` and the MDC `MatMenuModule`
@@ -27,10 +24,6 @@ import {
2724
declarations: [
2825
MatMenuTrigger,
2926
MatMenuContent,
30-
// TODO(devversion): remove when `MatMenu` becomes a selectorless Directive.
31-
MatMenu,
32-
// TODO(devversion): remove when `_MatMenuBase` becomes a selectorless Directive.
33-
_MatMenuBase
3427
],
3528
providers: [MAT_MENU_SCROLL_STRATEGY_FACTORY_PROVIDER]
3629
})

src/material/menu/menu.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,7 @@ const MAT_MENU_BASE_ELEVATION = 4;
9393
let menuPanelUid = 0;
9494

9595
/** Base class with all of the `MatMenu` functionality. */
96-
@Directive({
97-
// TODO(devversion): this selector can be removed when we update to Angular 9.0.
98-
selector: 'do-not-use-abstract-mat-menu-base'
99-
})
96+
@Directive()
10097
// tslint:disable-next-line:class-name
10198
export class _MatMenuBase implements AfterContentInit, MatMenuPanel<MatMenuItem>, OnInit,
10299
OnDestroy {
@@ -454,10 +451,7 @@ export class _MatMenuBase implements AfterContentInit, MatMenuPanel<MatMenuItem>
454451
}
455452

456453
/** @docs-private We show the "_MatMenu" class as "MatMenu" in the docs. */
457-
@Directive({
458-
// TODO(devversion): this selector can be removed when we update to Angular 9.0.
459-
selector: 'do-not-use-abstract-mat-menu'
460-
})
454+
@Directive()
461455
export class MatMenu extends _MatMenuBase {}
462456

463457
// Note on the weird inheritance setup: we need three classes, because the MDC-based menu has to

src/material/tabs/paginated-tab-header.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,7 @@ export type MatPaginatedTabHeaderItem = FocusableOption & {elementRef: ElementRe
6868
* Base class for a tab header that supported pagination.
6969
* @docs-private
7070
*/
71-
@Directive({
72-
// TODO(crisbeto): this selector can be removed when we update to Angular 9.0.
73-
selector: 'do-not-use-abstract-mat-paginated-tab-header'
74-
})
71+
@Directive()
7572
export abstract class MatPaginatedTabHeader implements AfterContentChecked, AfterContentInit,
7673
AfterViewInit, OnDestroy {
7774
abstract _items: QueryList<MatPaginatedTabHeaderItem>;

src/material/tabs/tab-body.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,7 @@ export class MatTabBodyPortal extends CdkPortalOutlet implements OnInit, OnDestr
108108
* Base class with all of the `MatTabBody` functionality.
109109
* @docs-private
110110
*/
111-
@Directive({
112-
// TODO(crisbeto): this selector can be removed when we update to Angular 9.0.
113-
selector: 'do-not-use-abstract-mat-tab-body-base'
114-
})
111+
@Directive()
115112
// tslint:disable-next-line:class-name
116113
export abstract class _MatTabBodyBase implements OnInit, OnDestroy {
117114
/** Current position of the tab-body in the tab-group. Zero means that the tab is visible. */

0 commit comments

Comments
 (0)