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