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 {
5858 tree . visit ( path => {
5959 if ( shouldRenameTokens ( path ) ) {
6060 const content = tree . readText ( path ) ;
61- const updatedContent = content . replace ( '--mdc-' , '--mat-' ) ;
61+ const updatedContent = content . replaceAll ( '--mdc-' , '--mat-' ) ;
6262 if ( content !== updatedContent ) {
6363 tree . overwrite ( path , updatedContent ) ;
6464 }
@@ -100,7 +100,7 @@ function renameComponentTokens(): Rule {
100100 const content = tree . readText ( path ) ;
101101 let updatedContent = content ;
102102 for ( const tokenPrefix of tokenPrefixes ) {
103- updatedContent = updatedContent . replace ( tokenPrefix . old , tokenPrefix . replacement ) ;
103+ updatedContent = updatedContent . replaceAll ( tokenPrefix . old , tokenPrefix . replacement ) ;
104104 }
105105 if ( content !== updatedContent ) {
106106 tree . overwrite ( path , updatedContent ) ;
Original file line number Diff line number Diff line change @@ -48,4 +48,58 @@ describe('v20 rename tokens migration', () => {
4848 ` ) ,
4949 ) ;
5050 } ) ;
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+ } ) ;
51105} ) ;
You can’t perform that action at this time.
0 commit comments