@@ -25,13 +25,35 @@ var RE_VAR_PROP = (/(--(.+))/);
25
25
function eachCssVariableDeclaration ( css , cb ) {
26
26
// Loop through all of the declarations and grab the variables and put them in the map
27
27
css . walkDecls ( function ( decl ) {
28
+ var isUnderSupportsCss = declIsInCssSupportsRule ( decl ) ;
28
29
// If declaration is a variable
29
- if ( RE_VAR_PROP . test ( decl . prop ) ) {
30
+ if ( RE_VAR_PROP . test ( decl . prop ) && ! isUnderSupportsCss ) {
30
31
cb ( decl ) ;
31
32
}
32
33
} ) ;
33
34
}
34
35
36
+ function declIsInCssSupportsRule ( decl ) {
37
+ if ( decl . parent && decl . parent . parent ) {
38
+ return checkIsCssSupportsRule ( decl . parent . parent ) ;
39
+ }
40
+ return false ;
41
+ } ;
42
+
43
+ function ruleIsInCssSupportsRule ( rule ) {
44
+ if ( rule . parent ) {
45
+ return checkIsCssSupportsRule ( rule . parent ) ;
46
+ }
47
+ return false ;
48
+ } ;
49
+
50
+ function checkIsCssSupportsRule ( node ) {
51
+ if ( node . type == 'atrule' && node . name === 'supports' && [ ] . concat ( node . params ) [ 0 ] . indexOf ( '--' ) > - 1 ) {
52
+ return true ;
53
+ }
54
+ return false ;
55
+ } ;
56
+
35
57
36
58
37
59
function cleanUpNode ( node ) {
@@ -209,6 +231,9 @@ module.exports = postcss.plugin('postcss-css-variables', function(options) {
209
231
// Collect all the rules that have declarations that use variables
210
232
var rulesThatHaveDeclarationsWithVariablesList = [ ] ;
211
233
css . walkRules ( function ( rule ) {
234
+ if ( ruleIsInCssSupportsRule ( rule ) ) {
235
+ return false ;
236
+ }
212
237
var doesRuleUseVariables = rule . nodes . some ( function ( node ) {
213
238
if ( node . type === 'decl' ) {
214
239
var decl = node ;
0 commit comments