File tree Expand file tree Collapse file tree 2 files changed +56
-2
lines changed
src/material/schematics/ng-update Expand file tree Collapse file tree 2 files changed +56
-2
lines changed Original file line number Diff line number Diff line change @@ -58,7 +58,7 @@ function renameMdcTokens(): Rule {
58
58
tree . visit ( path => {
59
59
if ( shouldRenameTokens ( path ) ) {
60
60
const content = tree . readText ( path ) ;
61
- const updatedContent = content . replace ( '--mdc-' , '--mat-' ) ;
61
+ const updatedContent = content . replaceAll ( '--mdc-' , '--mat-' ) ;
62
62
if ( content !== updatedContent ) {
63
63
tree . overwrite ( path , updatedContent ) ;
64
64
}
@@ -100,7 +100,7 @@ function renameComponentTokens(): Rule {
100
100
const content = tree . readText ( path ) ;
101
101
let updatedContent = content ;
102
102
for ( const tokenPrefix of tokenPrefixes ) {
103
- updatedContent = updatedContent . replace ( tokenPrefix . old , tokenPrefix . replacement ) ;
103
+ updatedContent = updatedContent . replaceAll ( tokenPrefix . old , tokenPrefix . replacement ) ;
104
104
}
105
105
if ( content !== updatedContent ) {
106
106
tree . overwrite ( path , updatedContent ) ;
Original file line number Diff line number Diff line change @@ -48,4 +48,58 @@ describe('v20 rename tokens migration', () => {
48
48
` ) ,
49
49
) ;
50
50
} ) ;
51
+
52
+ it ( 'should rename multiple instances of the --mdc prefix' , async ( ) => {
53
+ writeFile (
54
+ THEME_FILE_PATH ,
55
+ `
56
+ html {
57
+ --mdc-foo: 1px;
58
+ --mdc-bar: 2px;
59
+ --mdc-baz: 3px;
60
+ }
61
+ ` ,
62
+ ) ;
63
+
64
+ await runMigration ( ) ;
65
+
66
+ expect ( stripWhitespace ( tree . readText ( THEME_FILE_PATH ) ) ) . toBe (
67
+ stripWhitespace ( `
68
+ html {
69
+ --mat-foo: 1px;
70
+ --mat-bar: 2px;
71
+ --mat-baz: 3px;
72
+ }
73
+ ` ) ,
74
+ ) ;
75
+ } ) ;
76
+
77
+ it ( 'should rename multiple instances of a specific component token' , async ( ) => {
78
+ writeFile (
79
+ THEME_FILE_PATH ,
80
+ `
81
+ .one {
82
+ --mat-circular-progress-foo: 1px;
83
+ }
84
+
85
+ .two {
86
+ --mat-circular-progress-bar: 2px;
87
+ }
88
+ ` ,
89
+ ) ;
90
+
91
+ await runMigration ( ) ;
92
+
93
+ expect ( stripWhitespace ( tree . readText ( THEME_FILE_PATH ) ) ) . toBe (
94
+ stripWhitespace ( `
95
+ .one {
96
+ --mat-progress-spinner-foo: 1px;
97
+ }
98
+
99
+ .two {
100
+ --mat-progress-spinner-bar: 2px;
101
+ }
102
+ ` ) ,
103
+ ) ;
104
+ } ) ;
51
105
} ) ;
You can’t perform that action at this time.
0 commit comments