Skip to content

Commit

Permalink
refactor: remove abstract directive selector workaround
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
devversion committed Oct 23, 2019
1 parent d6e7893 commit bf0cf31
Show file tree
Hide file tree
Showing 14 changed files with 20 additions and 88 deletions.
5 changes: 1 addition & 4 deletions src/cdk-experimental/popover-edit/popover-edit.spec.ts
Expand Up @@ -61,10 +61,7 @@ interface PeriodicElement {
weight: number;
}

@Directive({
// TODO(devversion): this selector can be removed when we update to Angular 9.0.
selector: 'do-not-use-abstract-cdk-popover-edit-base-test-component'
})
@Directive()
abstract class BaseTestComponent {
@ViewChild('table', {static: false}) table: ElementRef;

Expand Down
10 changes: 2 additions & 8 deletions src/material-experimental/mdc-button/button-base.ts
Expand Up @@ -79,10 +79,7 @@ export const _MatButtonBaseMixin: CanDisableRippleCtor&CanDisableCtor&CanColorCt
typeof MatButtonMixinCore = mixinColor(mixinDisabled(mixinDisableRipple(MatButtonMixinCore)));

/** Base class for all buttons. */
@Directive({
// TODO(devversion): this selector can be removed when we update to Angular 9.0.
selector: 'do-not-use-abstract-mat-button-base'
})
@Directive()
export class MatButtonBase extends _MatButtonBaseMixin implements CanDisable, CanColor,
CanDisableRipple {
/** The ripple animation configuration to use for the buttons. */
Expand Down Expand Up @@ -154,10 +151,7 @@ export const MAT_ANCHOR_HOST = {
/**
* Anchor button base.
*/
@Directive({
// TODO(devversion): this selector can be removed when we update to Angular 9.0.
selector: 'do-not-use-abstract-mat-anchor-base'
})
@Directive()
export class MatAnchorBase extends MatButtonBase {
tabIndex: number;

Expand Down
5 changes: 0 additions & 5 deletions src/material-experimental/mdc-button/module.ts
Expand Up @@ -10,7 +10,6 @@ import {CommonModule} from '@angular/common';
import {NgModule} from '@angular/core';
import {MatCommonModule, MatRippleModule} from '@angular/material/core';
import {MatAnchor, MatButton} from './button';
import {MatAnchorBase, MatButtonBase} from './button-base';
import {MatFabAnchor, MatFabButton} from './fab';
import {MatIconAnchor, MatIconButton} from './icon-button';

Expand All @@ -32,10 +31,6 @@ import {MatIconAnchor, MatIconButton} from './icon-button';
MatIconButton,
MatFabAnchor,
MatFabButton,
// TODO(devversion): remove when `MatButtonBase` becomes a selectorless Directive.
MatButtonBase,
// TODO(devversion): remove when `MatAnchorBase` becomes a selectorless Directive.
MatAnchorBase,
],
})
export class MatButtonModule {
Expand Down
5 changes: 1 addition & 4 deletions src/material-experimental/popover-edit/popover-edit.spec.ts
Expand Up @@ -59,10 +59,7 @@ interface PeriodicElement {
weight: number;
}

@Directive({
// TODO(devversion): this selector can be removed when we update to Angular 9.0.
selector: 'do-not-use-abstract-mat-popover-edit-base-test-component'
})
@Directive()
abstract class BaseTestComponent {
@ViewChild('table', {static: false}) table: ElementRef;

Expand Down
7 changes: 1 addition & 6 deletions src/material/form-field/form-field-control.ts
Expand Up @@ -12,12 +12,7 @@ import {Directive} from '@angular/core';


/** An interface which allows a control to work inside of a `MatFormField`. */
@Directive({
// The @Directive with selector is required here because we're still running a lot of things
// against ViewEngine where directives without selectors are not allowed.
// TODO(crisbeto): convert to a selectorless Directive after we switch to Ivy.
selector: 'do-not-use-abstract-mat-form-field-control',
})
@Directive()
export abstract class MatFormFieldControl<T> {
/** The value of the control. */
value: T | null;
Expand Down
6 changes: 0 additions & 6 deletions src/material/form-field/form-field-module.ts
Expand Up @@ -16,8 +16,6 @@ import {MatLabel} from './label';
import {MatPlaceholder} from './placeholder';
import {MatPrefix} from './prefix';
import {MatSuffix} from './suffix';
import {MatFormFieldControl} from './form-field-control';


@NgModule({
declarations: [
Expand All @@ -28,10 +26,6 @@ import {MatFormFieldControl} from './form-field-control';
MatPlaceholder,
MatPrefix,
MatSuffix,

// TODO(crisbeto): can be removed once `MatFormFieldControl`
// is turned into a selector-less directive.
MatFormFieldControl as any,
],
imports: [
CommonModule,
Expand Down
11 changes: 2 additions & 9 deletions src/material/menu/menu-module.ts
Expand Up @@ -10,13 +10,10 @@ import {OverlayModule} from '@angular/cdk/overlay';
import {CommonModule} from '@angular/common';
import {NgModule} from '@angular/core';
import {MatCommonModule, MatRippleModule} from '@angular/material/core';
import {_MatMenu} from './menu';
import {MatMenuContent} from './menu-content';
import {_MatMenu, _MatMenuBase, MatMenu} from './menu';
import {MatMenuItem} from './menu-item';
import {
MatMenuTrigger,
MAT_MENU_SCROLL_STRATEGY_FACTORY_PROVIDER,
} from './menu-trigger';
import {MAT_MENU_SCROLL_STRATEGY_FACTORY_PROVIDER, MatMenuTrigger,} from './menu-trigger';

/**
* Used by both the current `MatMenuModule` and the MDC `MatMenuModule`
Expand All @@ -27,10 +24,6 @@ import {
declarations: [
MatMenuTrigger,
MatMenuContent,
// TODO(devversion): remove when `MatMenu` becomes a selectorless Directive.
MatMenu,
// TODO(devversion): remove when `_MatMenuBase` becomes a selectorless Directive.
_MatMenuBase
],
providers: [MAT_MENU_SCROLL_STRATEGY_FACTORY_PROVIDER]
})
Expand Down
10 changes: 2 additions & 8 deletions src/material/menu/menu.ts
Expand Up @@ -93,10 +93,7 @@ const MAT_MENU_BASE_ELEVATION = 4;
let menuPanelUid = 0;

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

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

// Note on the weird inheritance setup: we need three classes, because the MDC-based menu has to
Expand Down
5 changes: 1 addition & 4 deletions src/material/tabs/paginated-tab-header.ts
Expand Up @@ -68,10 +68,7 @@ export type MatPaginatedTabHeaderItem = FocusableOption & {elementRef: ElementRe
* Base class for a tab header that supported pagination.
* @docs-private
*/
@Directive({
// TODO(crisbeto): this selector can be removed when we update to Angular 9.0.
selector: 'do-not-use-abstract-mat-paginated-tab-header'
})
@Directive()
export abstract class MatPaginatedTabHeader implements AfterContentChecked, AfterContentInit,
AfterViewInit, OnDestroy {
abstract _items: QueryList<MatPaginatedTabHeaderItem>;
Expand Down
5 changes: 1 addition & 4 deletions src/material/tabs/tab-body.ts
Expand Up @@ -102,10 +102,7 @@ export class MatTabBodyPortal extends CdkPortalOutlet implements OnInit, OnDestr
* Base class with all of the `MatTabBody` functionality.
* @docs-private
*/
@Directive({
// TODO(crisbeto): this selector can be removed when we update to Angular 9.0.
selector: 'do-not-use-abstract-mat-tab-body-base'
})
@Directive()
// tslint:disable-next-line:class-name
export abstract class _MatTabBodyBase implements OnInit, OnDestroy {
/** Current position of the tab-body in the tab-group. Zero means that the tab is visible. */
Expand Down
5 changes: 1 addition & 4 deletions src/material/tabs/tab-group.ts
Expand Up @@ -88,10 +88,7 @@ interface MatTabGroupBaseHeader {
* Base class with all of the `MatTabGroupBase` functionality.
* @docs-private
*/
@Directive({
// TODO(crisbeto): this selector can be removed when we update to Angular 9.0.
selector: 'do-not-use-abstract-mat-tab-group-base'
})
@Directive()
// tslint:disable-next-line:class-name
export abstract class _MatTabGroupBase extends _MatTabGroupMixinBase implements AfterContentInit,
AfterContentChecked, OnDestroy, CanColor, CanDisableRipple {
Expand Down
5 changes: 1 addition & 4 deletions src/material/tabs/tab-header.ts
Expand Up @@ -38,10 +38,7 @@ import {MatPaginatedTabHeader} from './paginated-tab-header';
* Base class with all of the `MatTabHeader` functionality.
* @docs-private
*/
@Directive({
// TODO(crisbeto): this selector can be removed when we update to Angular 9.0.
selector: 'do-not-use-abstract-mat-tab-header-base'
})
@Directive()
// tslint:disable-next-line:class-name
export abstract class _MatTabHeaderBase extends MatPaginatedTabHeader implements
AfterContentChecked, AfterContentInit, AfterViewInit, OnDestroy {
Expand Down
10 changes: 2 additions & 8 deletions src/material/tabs/tab-nav-bar/tab-nav-bar.ts
Expand Up @@ -52,10 +52,7 @@ import {startWith, takeUntil} from 'rxjs/operators';
* Base class with all of the `MatTabNav` functionality.
* @docs-private
*/
@Directive({
// TODO(crisbeto): this selector can be removed when we update to Angular 9.0.
selector: 'do-not-use-abstract-mat-tab-nav-base'
})
@Directive()
// tslint:disable-next-line:class-name
export abstract class _MatTabNavBase extends MatPaginatedTabHeader implements AfterContentChecked,
AfterContentInit, OnDestroy {
Expand Down Expand Up @@ -192,10 +189,7 @@ const _MatTabLinkMixinBase:
mixinTabIndex(mixinDisableRipple(mixinDisabled(MatTabLinkMixinBase)));

/** Base class with all of the `MatTabLink` functionality. */
@Directive({
// TODO(crisbeto): this selector can be removed when we update to Angular 9.0.
selector: 'do-not-use-abstract-mat-tab-link-base'
})
@Directive()
// tslint:disable-next-line:class-name
export class _MatTabLinkBase extends _MatTabLinkMixinBase implements OnDestroy, CanDisable,
CanDisableRipple, HasTabIndex, RippleTarget, FocusableOption {
Expand Down
19 changes: 5 additions & 14 deletions src/material/tabs/tabs-module.ts
Expand Up @@ -6,22 +6,21 @@
* found in the LICENSE file at https://angular.io/license
*/

import {A11yModule} from '@angular/cdk/a11y';
import {ObserversModule} from '@angular/cdk/observers';
import {PortalModule} from '@angular/cdk/portal';
import {CommonModule} from '@angular/common';
import {NgModule} from '@angular/core';
import {A11yModule} from '@angular/cdk/a11y';
import {MatCommonModule, MatRippleModule} from '@angular/material/core';
import {MatInkBar} from './ink-bar';
import {MatTab} from './tab';
import {MatTabBody, MatTabBodyPortal, _MatTabBodyBase} from './tab-body';
import {MatTabBody, MatTabBodyPortal} from './tab-body';
import {MatTabContent} from './tab-content';
import {MatTabGroup, _MatTabGroupBase} from './tab-group';
import {MatTabHeader, _MatTabHeaderBase} from './tab-header';
import {MatTabGroup} from './tab-group';
import {MatTabHeader} from './tab-header';
import {MatTabLabel} from './tab-label';
import {MatTabLabelWrapper} from './tab-label-wrapper';
import {MatTabLink, MatTabNav, _MatTabNavBase, _MatTabLinkBase} from './tab-nav-bar/tab-nav-bar';
import {MatPaginatedTabHeader} from './paginated-tab-header';
import {MatTabLink, MatTabNav} from './tab-nav-bar/tab-nav-bar';


@NgModule({
Expand Down Expand Up @@ -55,14 +54,6 @@ import {MatPaginatedTabHeader} from './paginated-tab-header';
MatTabBodyPortal,
MatTabHeader,
MatTabContent,

// TODO(crisbeto): these can be removed once they're turned into selector-less directives.
MatPaginatedTabHeader as any,
_MatTabGroupBase as any,
_MatTabNavBase as any,
_MatTabBodyBase as any,
_MatTabHeaderBase as any,
_MatTabLinkBase as any,
],
})
export class MatTabsModule {}

0 comments on commit bf0cf31

Please sign in to comment.