File tree 4 files changed +13
-8
lines changed 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) {
39
39
var /*match*/ key = _matches2 [ 1 ] ;
40
40
var value = _matches2 [ 2 ] ;
41
41
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 ) ;
45
44
atRule . remove ( ) ;
46
45
}
47
46
} ;
Original file line number Diff line number Diff line change 34
34
"standard" : " ^5.3.1"
35
35
},
36
36
"dependencies" : {
37
- "icss-replace-symbols" : " ^1.0.1 " ,
37
+ "icss-replace-symbols" : " ^1.0.2 " ,
38
38
"postcss" : " ^5.0.10"
39
39
}
40
40
}
Original file line number Diff line number Diff line change 1
1
import postcss from 'postcss'
2
- import replaceSymbols from 'icss-replace-symbols'
2
+ import replaceSymbols , { replaceAll } from 'icss-replace-symbols'
3
3
4
4
const matchImports = / ^ ( .+ ?) \s + f r o m \s + ( " [ ^ " ] * " | ' [ ^ ' ] * ' | [ \w - ] + ) $ /
5
5
const matchLet = / (?: , \s + | ^ ) ( [ \w - ] + ) : ? \s + ( " [ ^ " ] * " | ' [ ^ ' ] * ' | [ ^ , ] + ) \s ? / g
@@ -16,9 +16,8 @@ export default css => {
16
16
let matches
17
17
while ( matches = matchLet . exec ( atRule . params ) ) {
18
18
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 )
22
21
atRule . remove ( )
23
22
}
24
23
}
Original file line number Diff line number Diff line change @@ -78,5 +78,12 @@ describe('constants', () => {
78
78
':export {\n aaa: red;\n bbb: red;\n}\n.a { color: red; }'
79
79
)
80
80
} )
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
+ } )
81
88
} )
82
89
You can’t perform that action at this time.
0 commit comments