Skip to content

Commit

Permalink
fix(material/schematics): update deprecated prefix field to take mult…
Browse files Browse the repository at this point in the history
…iple prefixes
  • Loading branch information
amysorto authored and mmalerba committed Jul 15, 2022
1 parent 6b24f96 commit 19008ef
Show file tree
Hide file tree
Showing 15 changed files with 18 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {ClassNameChange, StyleMigrator} from '../../style-migrator';
export class ButtonStylesMigrator extends StyleMigrator {
component = 'button';

deprecatedPrefix = 'mat-button';
deprecatedPrefixes = ['mat-button'];

mixinChanges = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {ClassNameChange, StyleMigrator} from '../../style-migrator';
export class CardStylesMigrator extends StyleMigrator {
component = 'card';

deprecatedPrefix = 'mat-card';
deprecatedPrefixes = ['mat-card'];

mixinChanges = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {ClassNameChange, StyleMigrator} from '../../style-migrator';
export class CheckboxStylesMigrator extends StyleMigrator {
component = 'checkbox';

deprecatedPrefix = 'mat-checkbox';
deprecatedPrefixes = ['mat-checkbox'];

mixinChanges = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {ClassNameChange, StyleMigrator} from '../../style-migrator';
export class ChipsStylesMigrator extends StyleMigrator {
component = 'chips';

deprecatedPrefix = 'mat-chip';
deprecatedPrefixes = ['mat-chip'];

mixinChanges = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {ClassNameChange, StyleMigrator} from '../../style-migrator';
export class DialogStylesMigrator extends StyleMigrator {
component = 'dialog';

deprecatedPrefix = 'mat-dialog';
deprecatedPrefixes = ['mat-dialog'];

mixinChanges = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {ClassNameChange, StyleMigrator} from '../../style-migrator';
export class ListStylesMigrator extends StyleMigrator {
component = 'list';

deprecatedPrefix = 'mat-list';
deprecatedPrefixes = ['mat-list'];

mixinChanges = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {ClassNameChange, StyleMigrator} from '../../style-migrator';
export class MenuStylesMigrator extends StyleMigrator {
component = 'menu';

deprecatedPrefix = 'mat-menu';
deprecatedPrefixes = ['mat-menu'];

mixinChanges = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {ClassNameChange, StyleMigrator} from '../../style-migrator';
export class PaginatorStylesMigrator extends StyleMigrator {
component = 'paginator';

deprecatedPrefix = 'mat-paginator';
deprecatedPrefixes = ['mat-paginator'];

mixinChanges = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {ClassNameChange, StyleMigrator} from '../../style-migrator';
export class ProgressBarStylesMigrator extends StyleMigrator {
component = 'progress-bar';

deprecatedPrefix = 'mat-progress-bar';
deprecatedPrefixes = ['mat-progress-bar'];

mixinChanges = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class ProgressSpinnerStylesMigrator extends StyleMigrator {

// There are no other progress spinner selectors available aside from the
// specified changes below
deprecatedPrefix = null;
deprecatedPrefixes = [];

mixinChanges = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {ClassNameChange, StyleMigrator} from '../../style-migrator';
export class RadioStylesMigrator extends StyleMigrator {
component = 'radio';

deprecatedPrefix = 'mat-radio';
deprecatedPrefixes = ['mat-radio'];

mixinChanges = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {ClassNameChange, StyleMigrator} from '../../style-migrator';
export class SlideToggleStylesMigrator extends StyleMigrator {
component = 'slide-toggle';

deprecatedPrefix = 'mat-slide-toggle';
deprecatedPrefixes = ['mat-slide-toggle'];

mixinChanges = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {ClassNameChange, StyleMigrator} from '../../style-migrator';
export class SliderStylesMigrator extends StyleMigrator {
component = 'slider';

deprecatedPrefix = 'mat-slider';
deprecatedPrefixes = ['mat-slider'];

mixinChanges = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class TableStylesMigrator extends StyleMigrator {

// There are no other table selectors available aside from the specified
// changes below
deprecatedPrefix = null;
deprecatedPrefixes = [];

mixinChanges = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export abstract class StyleMigrator {
abstract mixinChanges: MixinChange[];

/** The prefix of classes that are specific to the old components */
abstract deprecatedPrefix: string | null;
abstract deprecatedPrefixes: string[];

/**
* Returns whether the given at-include at-rule is a use of a legacy mixin for this component.
Expand Down Expand Up @@ -146,7 +146,9 @@ export abstract class StyleMigrator {
* @returns `true` if the given Rule uses a selector with the deprecated prefix.
*/
isDeprecatedSelector(rule: postcss.Rule): boolean {
return this.deprecatedPrefix ? rule.selector.includes(this.deprecatedPrefix) : false;
return this.deprecatedPrefixes.some(deprecatedPrefix =>
rule.selector.includes(deprecatedPrefix),
);
}

/**
Expand Down

0 comments on commit 19008ef

Please sign in to comment.