File tree Expand file tree Collapse file tree 4 files changed +13
-8
lines changed Expand file tree Collapse file tree 4 files changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -39,9 +39,8 @@ exports['default'] = function (css) {
3939 var /*match*/ key = _matches2 [ 1 ] ;
4040 var value = _matches2 [ 2 ] ;
4141
42- // Values can refer to each other
43- if ( definitions [ value ] ) value = definitions [ value ] ;
44- definitions [ key ] = value ;
42+ // Add to the definitions, knowing that values can refer to each other
43+ definitions [ key ] = ( 0 , _icssReplaceSymbols . replaceAll ) ( definitions , value ) ;
4544 atRule . remove ( ) ;
4645 }
4746 } ;
Original file line number Diff line number Diff line change 3434 "standard" : " ^5.3.1"
3535 },
3636 "dependencies" : {
37- "icss-replace-symbols" : " ^1.0.1 " ,
37+ "icss-replace-symbols" : " ^1.0.2 " ,
3838 "postcss" : " ^5.0.10"
3939 }
4040}
Original file line number Diff line number Diff line change 11import postcss from 'postcss'
2- import replaceSymbols from 'icss-replace-symbols'
2+ import replaceSymbols , { replaceAll } from 'icss-replace-symbols'
33
44const matchImports = / ^ ( .+ ?) \s + f r o m \s + ( " [ ^ " ] * " | ' [ ^ ' ] * ' | [ \w - ] + ) $ /
55const matchLet = / (?: , \s + | ^ ) ( [ \w - ] + ) : ? \s + ( " [ ^ " ] * " | ' [ ^ ' ] * ' | [ ^ , ] + ) \s ? / g
@@ -16,9 +16,8 @@ export default css => {
1616 let matches
1717 while ( matches = matchLet . exec ( atRule . params ) ) {
1818 let [ /*match*/ , key , value ] = matches
19- // Values can refer to each other
20- if ( definitions [ value ] ) value = definitions [ value ]
21- definitions [ key ] = value
19+ // Add to the definitions, knowing that values can refer to each other
20+ definitions [ key ] = replaceAll ( definitions , value )
2221 atRule . remove ( )
2322 }
2423 }
Original file line number Diff line number Diff line change @@ -78,5 +78,12 @@ describe('constants', () => {
7878 ':export {\n aaa: red;\n bbb: red;\n}\n.a { color: red; }'
7979 )
8080 } )
81+
82+ it ( 'should allow transitive values within calc' , ( ) => {
83+ test (
84+ '@value base: 10px;\n@value large: calc(base * 2);\n.a { margin: large; }' ,
85+ ':export {\n base: 10px;\n large: calc(10px * 2);\n}\n.a { margin: calc(10px * 2); }'
86+ )
87+ } )
8188} )
8289
You can’t perform that action at this time.
0 commit comments