border-radius.js 1.2 KB

1234567891011121314151617181920212223242526272829
  1. var OptimizationLevel = require('../../../options/optimization-level').OptimizationLevel;
  2. var plugin = {
  3. level1: {
  4. property: function borderRadius(_rule, property, options) {
  5. var values = property.value;
  6. if (!options.level[OptimizationLevel.One].optimizeBorderRadius) {
  7. return;
  8. }
  9. if (values.length == 3 && values[1][1] == '/' && values[0][1] == values[2][1]) {
  10. property.value.splice(1);
  11. property.dirty = true;
  12. } else if (values.length == 5 && values[2][1] == '/' && values[0][1] == values[3][1] && values[1][1] == values[4][1]) {
  13. property.value.splice(2);
  14. property.dirty = true;
  15. } else if (values.length == 7 && values[3][1] == '/' && values[0][1] == values[4][1] && values[1][1] == values[5][1] && values[2][1] == values[6][1]) {
  16. property.value.splice(3);
  17. property.dirty = true;
  18. } else if (values.length == 9 && values[4][1] == '/' && values[0][1] == values[5][1] && values[1][1] == values[6][1] && values[2][1] == values[7][1] && values[3][1] == values[8][1]) {
  19. property.value.splice(4);
  20. property.dirty = true;
  21. }
  22. }
  23. }
  24. };
  25. module.exports = plugin;