@@ -14,10 +14,16 @@ var VAR_FUNC_IDENTIFIER = "var"
14
14
// matches `name[, fallback]`, captures "name" and "fallback"
15
15
var RE_VAR = / ( [ \w - ] + ) (?: \s * , \s * ) ? \s * ( .* ) ? /
16
16
17
+ /**
18
+ * Module variables
19
+ */
20
+
21
+ var warnings
22
+
17
23
/**
18
24
* Resolve CSS variables.
19
25
*
20
- * The second argument to the CSS variable function, var(name[, fallback]),
26
+ * The second argument to the CSS variable function, var(name[, fallback]),
21
27
* is used in the event that first argument cannot be resolved.
22
28
*
23
29
* @param {String } value May contain the CSS variable function
@@ -50,10 +56,12 @@ function resolveValue(value, variables, result, decl) {
50
56
var post
51
57
// undefined and without fallback, just keep original value
52
58
if ( ! variable && ! fallback ) {
53
- result . warn (
54
- "variable '" + name + "' is undefined and used without a fallback" ,
55
- { node : decl }
56
- )
59
+ if ( warnings ) {
60
+ result . warn (
61
+ "variable '" + name + "' is undefined and used without a fallback" ,
62
+ { node : decl }
63
+ )
64
+ }
57
65
post = matches . post
58
66
? resolveValue ( matches . post , variables , result , decl )
59
67
: [ "" ]
@@ -91,7 +99,9 @@ function resolveValue(value, variables, result, decl) {
91
99
// circular reference encountered
92
100
if ( variable . deps . indexOf ( name ) !== - 1 ) {
93
101
if ( ! fallback ) {
94
- result . warn ( "Circular variable reference: " + name , { node : decl } )
102
+ if ( warnings ) {
103
+ result . warn ( "Circular variable reference: " + name , { node : decl } )
104
+ }
95
105
variable . value = [ variable . value ]
96
106
variable . circular = true
97
107
}
@@ -153,14 +163,15 @@ module.exports = postcss.plugin("postcss-custom-properties", function(options) {
153
163
}
154
164
155
165
function plugin ( style , result ) {
156
- var warnings = options . warnings === undefined ? true : options . warnings
157
166
var variables = prefixVariables ( options . variables )
158
167
var strict = options . strict === undefined ? true : options . strict
159
168
var appendVariables = options . appendVariables
160
169
var preserve = options . preserve
161
170
var map = { }
162
171
var importantMap = { }
163
172
173
+ warnings = options . warnings === undefined ? true : options . warnings
174
+
164
175
// define variables
165
176
style . walkRules ( function ( rule ) {
166
177
var toRemove = [ ]
0 commit comments