Skip to content

Commit 7b7ad32

Browse files
committed
fix(material/schematics): add missing legacy sass mixin transforms
1 parent b88e2ee commit 7b7ad32

File tree

3 files changed

+30
-14
lines changed

3 files changed

+30
-14
lines changed

src/material/schematics/ng-update/migrations/legacy-components-v15/constants.ts

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,23 @@ export const CUSTOM_TS_SYMBOL_RENAMINGS = [
8989
{old: 'SCROLL_THROTTLE_MS', new: 'LEGACY_SCROLL_THROTTLE_MS'},
9090
];
9191

92-
export const MIXINS = COMPONENTS.concat(['option', 'optgroup']).flatMap(component => [
93-
`${component}-theme`,
94-
`${component}-color`,
95-
`${component}-density`,
96-
`${component}-typography`,
97-
]);
92+
export const COMPONENT_THEME_MIXINS = COMPONENTS.concat(['option', 'optgroup']).flatMap(
93+
component => [
94+
`${component}-theme`,
95+
`${component}-color`,
96+
`${component}-density`,
97+
`${component}-typography`,
98+
],
99+
);
100+
101+
export const CUSTOM_SASS_MIXIN_RENAMINGS: {[key: string]: string} = {
102+
'all-component-themes': 'all-legacy-component-themes',
103+
'all-component-colors': 'all-legacy-component-colors',
104+
'all-component-typographies': 'all-legacy-component-typographies',
105+
'private-all-component-densities': 'private-all-legacy-component-densities',
106+
'core': 'legacy-core',
107+
};
108+
109+
export const CUSTOM_SASS_FUNCTION_RENAMINGS = {
110+
'define-typography-config': 'define-legacy-typography-config',
111+
};

src/material/schematics/ng-update/migrations/legacy-components-v15/index.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ import {
1414
CUSTOM_TS_SYMBOL_RENAMINGS,
1515
MAT_IMPORT_CHANGES,
1616
MDC_IMPORT_CHANGES,
17-
MIXINS,
17+
COMPONENT_THEME_MIXINS,
18+
CUSTOM_SASS_MIXIN_RENAMINGS,
1819
} from './constants';
1920

2021
import {Migration, ResolvedResource, TargetVersion, WorkspacePath} from '@angular/cdk/schematics';
@@ -55,10 +56,11 @@ export class LegacyComponentsMigration extends Migration<null> {
5556
if (!namespace || !node.source?.start) {
5657
return;
5758
}
58-
if (node.params.startsWith(`${namespace}.all-component-`)) {
59+
const mixinName = node.params.split(/[.(;]/)[1];
60+
if (CUSTOM_SASS_MIXIN_RENAMINGS[mixinName]) {
5961
this._replaceAt(filePath, node.source.start.offset, {
60-
old: `${namespace}.all-`,
61-
new: `${namespace}.all-legacy-`,
62+
old: `${namespace}.${mixinName}`,
63+
new: `${namespace}.${CUSTOM_SASS_MIXIN_RENAMINGS[mixinName]}`,
6264
});
6365
} else if (this._isLegacyMixin(node, namespace)) {
6466
this._replaceAt(filePath, node.source.start.offset, {
@@ -73,8 +75,8 @@ export class LegacyComponentsMigration extends Migration<null> {
7375
if (!node.params.startsWith(`${namespace}.`)) {
7476
return false;
7577
}
76-
for (let i = 0; i < MIXINS.length; i++) {
77-
if (node.params.startsWith(`${namespace}.${MIXINS[i]}`)) {
78+
for (let i = 0; i < COMPONENT_THEME_MIXINS.length; i++) {
79+
if (node.params.startsWith(`${namespace}.${COMPONENT_THEME_MIXINS[i]}`)) {
7880
return true;
7981
}
8082
}

src/material/schematics/ng-update/test-cases/v15/legacy-components-v15.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,14 +182,14 @@ describe('v15 legacy components migration', () => {
182182
`@use '@angular/material' as mat;`,
183183
`@include mat.all-component-themes($theme);`,
184184
`@include mat.all-component-colors($theme);`,
185-
`@include mat.all-component-densities($theme);`,
185+
`@include mat.private-all-component-densities($theme);`,
186186
`@include mat.all-component-typographies($theme);`,
187187
];
188188
const newFile: string[] = [
189189
`@use '@angular/material' as mat;`,
190190
`@include mat.all-legacy-component-themes($theme);`,
191191
`@include mat.all-legacy-component-colors($theme);`,
192-
`@include mat.all-legacy-component-densities($theme);`,
192+
`@include mat.private-all-legacy-component-densities($theme);`,
193193
`@include mat.all-legacy-component-typographies($theme);`,
194194
];
195195
for (let i = 0; i < COMPONENTS.length; i++) {

0 commit comments

Comments
 (0)