You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
922 B

3 months ago
  1. var OptimizationLevel = require('../../../options/optimization-level').OptimizationLevel;
  2. function isNegative(value) {
  3. return value && value[1][0] == '-' && parseFloat(value[1]) < 0;
  4. }
  5. var plugin = {
  6. level1: {
  7. property: function padding(_rule, property, options) {
  8. var values = property.value;
  9. // remove multiple zeros
  10. if (values.length == 4 && values[0][1] === '0' && values[1][1] === '0' && values[2][1] === '0' && values[3][1] === '0') {
  11. property.value.splice(1);
  12. property.dirty = true;
  13. }
  14. // remove negative paddings
  15. if (options.level[OptimizationLevel.One].removeNegativePaddings
  16. && (
  17. isNegative(property.value[0])
  18. || isNegative(property.value[1])
  19. || isNegative(property.value[2])
  20. || isNegative(property.value[3])
  21. )) {
  22. property.unused = true;
  23. }
  24. }
  25. }
  26. };
  27. module.exports = plugin;