@@ -249,12 +249,14 @@ function getGradientFromRule(rule) {
249
249
250
250
module . exports = postcss . plugin ( 'postcss-filter-gradient' , function ( opts ) {
251
251
opts = opts || { } ;
252
- opts . angleFallback =
253
- opts . angleFallback === undefined ? true : opts . angleFallback ;
254
- opts . skipMultiColor =
255
- opts . skipMultiColor === undefined ? false : opts . skipMultiColor ;
256
- opts . skipWarnings =
257
- opts . skipWarnings === undefined ? false : opts . skipWarnings ;
252
+ opts . angleFallback = opts . angleFallback !== false ;
253
+ opts . skipMultiColor = opts . skipMultiColor === true ;
254
+ opts . skipWarnings = opts . skipWarnings === true ;
255
+
256
+ function warn ( target , result , message ) {
257
+ if ( opts . skipWarnings ) return ;
258
+ target . warn ( result , message ) ;
259
+ }
258
260
259
261
return function ( root , result ) {
260
262
root . walkRules ( function ( rule ) {
@@ -263,20 +265,19 @@ module.exports = postcss.plugin('postcss-filter-gradient', function (opts) {
263
265
264
266
gradient = getGradientFromRule ( rule ) ;
265
267
266
- if ( opts . skipWarnings === false ) {
267
- // if linear-gradient and `filter` both exist, warn users
268
- if ( gradient . value && hasFilter ( rule ) ) {
269
- rule . warn (
270
- result ,
271
- 'The `filter` declaration already exists, we have skipped this rule.'
272
- ) ;
273
- return ;
274
- }
268
+ // if linear-gradient and `filter` both exist, warn users
269
+ if ( gradient . value && hasFilter ( rule ) ) {
270
+ warn (
271
+ rule ,
272
+ result ,
273
+ 'The `filter` declaration already exists, we have skipped this rule.'
274
+ ) ;
275
+ return ;
275
276
}
276
277
277
278
278
279
if ( gradient . warnings ) {
279
- gradient . decl . warn ( result , gradient . warnings ) ;
280
+ warn ( gradient . decl , result , gradient . warnings ) ;
280
281
}
281
282
282
283
if ( ! gradient . value ) {
@@ -287,7 +288,7 @@ module.exports = postcss.plugin('postcss-filter-gradient', function (opts) {
287
288
288
289
// warn users when the gradient value is not valid.
289
290
if ( ! filter . success ) {
290
- gradient . decl . warn ( result , filter . message ) ;
291
+ warn ( gradient . decl , result , filter . message ) ;
291
292
return ;
292
293
}
293
294
@@ -301,7 +302,7 @@ module.exports = postcss.plugin('postcss-filter-gradient', function (opts) {
301
302
302
303
// warn developer when `filter.message` is not empty
303
304
if ( filter . message ) {
304
- gradient . decl . warn ( result , filter . message ) ;
305
+ warn ( gradient . decl , result , filter . message ) ;
305
306
}
306
307
307
308
// append filter string
0 commit comments