Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/material/schematics/ng-update/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function renameMdcTokens(): Rule {
tree.visit(path => {
if (shouldRenameTokens(path)) {
const content = tree.readText(path);
const updatedContent = content.replace('--mdc-', '--mat-');
const updatedContent = content.replaceAll('--mdc-', '--mat-');
if (content !== updatedContent) {
tree.overwrite(path, updatedContent);
}
Expand Down Expand Up @@ -100,7 +100,7 @@ function renameComponentTokens(): Rule {
const content = tree.readText(path);
let updatedContent = content;
for (const tokenPrefix of tokenPrefixes) {
updatedContent = updatedContent.replace(tokenPrefix.old, tokenPrefix.replacement);
updatedContent = updatedContent.replaceAll(tokenPrefix.old, tokenPrefix.replacement);
}
if (content !== updatedContent) {
tree.overwrite(path, updatedContent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,58 @@ describe('v20 rename tokens migration', () => {
`),
);
});

it('should rename multiple instances of the --mdc prefix', async () => {
writeFile(
THEME_FILE_PATH,
`
html {
--mdc-foo: 1px;
--mdc-bar: 2px;
--mdc-baz: 3px;
}
`,
);

await runMigration();

expect(stripWhitespace(tree.readText(THEME_FILE_PATH))).toBe(
stripWhitespace(`
html {
--mat-foo: 1px;
--mat-bar: 2px;
--mat-baz: 3px;
}
`),
);
});

it('should rename multiple instances of a specific component token', async () => {
writeFile(
THEME_FILE_PATH,
`
.one {
--mat-circular-progress-foo: 1px;
}

.two {
--mat-circular-progress-bar: 2px;
}
`,
);

await runMigration();

expect(stripWhitespace(tree.readText(THEME_FILE_PATH))).toBe(
stripWhitespace(`
.one {
--mat-progress-spinner-foo: 1px;
}

.two {
--mat-progress-spinner-bar: 2px;
}
`),
);
});
});
Loading