Blame view

node_modules/postcss-discard-empty/dist/index.js 909 Bytes
aaac7fed   liuqimichale   add
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
  'use strict';
  
  exports.__esModule = true;
  
  var _postcss = require('postcss');
  
  function discardAndReport(css, result) {
      function discardEmpty(node) {
          var type = node.type;
          var sub = node.nodes;
  
  
          if (sub) {
              node.each(discardEmpty);
          }
  
          if (type === 'decl' && !node.value || type === 'rule' && !node.selector || sub && !sub.length || type === 'atrule' && (!sub && !node.params || !node.params && !sub.length)) {
              node.remove();
  
              result.messages.push({
                  type: 'removal',
                  plugin: 'postcss-discard-empty',
                  node: node
              });
          }
      }
  
      css.each(discardEmpty);
  }
  
  exports.default = (0, _postcss.plugin)('postcss-discard-empty', function () {
      return function (css, result) {
          return discardAndReport(css, result);
      };
  });
  module.exports = exports['default'];