Replaces same horizontal & vertical value in border-radius.
authorJakub Pawlowicz <contact@jakubpawlowicz.com>
Sun, 29 Jun 2014 22:16:46 +0000 (23:16 +0100)
committerJakub Pawlowicz <contact@jakubpawlowicz.com>
Sun, 29 Jun 2014 22:28:05 +0000 (23:28 +0100)
* border-radius:1em/1em can be turned into border-radius:1em.

History.md
lib/clean.js
lib/properties/processable.js
test/unit-test.js

index b59842d..e42ccb7 100644 (file)
@@ -2,6 +2,7 @@
 ==================
 
 * Adds removing extra spaces around / in border-radius.
+* Adds replacing same horizontal & vertical value in border-radius.
 * Fixed issue [#305](https://github.com/GoalSmashers/clean-css/issues/305) - allows width keywords in border-width.
 
 [2.2.4 / 2014-06-27](https://github.com/GoalSmashers/clean-css/compare/v2.2.3...v2.2.4)
index a414506..d5d4168 100644 (file)
@@ -349,6 +349,16 @@ var minify = function(data, callback) {
   // replace ' / ' in border-*-radius with '/'
   replace(/(border-\w+-\w+-radius:\S+)\s+\/\s+/g, '$1/');
 
+  // replace same H/V values in border-radius
+  replace(/(border-\w+-\w+-radius):([^;\}]+)/g, function (match, property, value) {
+    var parts = value.split('/');
+
+    if (parts.length > 1 && parts[0] == parts[1])
+      return property + ':' + parts[0];
+    else
+      return match;
+  });
+
   replace(function restoreUrls() {
     data = urlsProcessor.restore(data);
   });
index f1f3fc1..35fa82b 100644 (file)
@@ -529,7 +529,8 @@ module.exports = (function () {
       var result = putTogether.takeCareOfInherit(putTogether.fourUnits)(prop, tokens, isImportant);
       if (verticalTokens.length > 0) {
         var verticalResult = putTogether.takeCareOfInherit(putTogether.fourUnits)(prop, verticalTokens, isImportant);
-        result.value += '/' + verticalResult.value;
+        if (result.value != verticalResult.value)
+          result.value += '/' + verticalResult.value;
       }
 
       return result;
index 31cdbe5..84fd2a1 100644 (file)
@@ -778,6 +778,28 @@ vows.describe('clean-units').addBatch({
     'keeps rgba(0,255,0,.5)': 'a{color:rgba(0,255,0,.5)}',
     'keeps hsla(120,100%,50%,.5)': 'a{color:hsla(120,100%,50%,.5)}'
   }),
+  'border-radius': cssContext({
+    'border radius H+V 0/0': [
+      'a{border-radius:0 / 0}',
+      'a{border-radius:0}'
+    ],
+    'border radius side H+V 0/0': [
+      'a{border-top-left-radius:0 / 0}',
+      'a{border-top-left-radius:0}'
+    ],
+    'border radius H+V same values': [
+      'a{border-radius:5px / 5px}',
+      'a{border-radius:5px}'
+    ],
+    'border radius side H+V same values': [
+      'a{border-top-left-radius:1em / 1em}',
+      'a{border-top-left-radius:1em}'
+    ],
+    'border radius H+V same expanded values': [
+      'a{border-radius:5px 5px 5px 5px / 5px 5px}',
+      'a{border-radius:5px}'
+    ]
+  }),
   'shortening colors': colorShorteningContext(),
   'font weights': cssContext({
     'font-weight:normal to 400': [
@@ -1953,8 +1975,8 @@ title']{display:block}",
       'a{outline:-webkit-focus-ring-color auto 5px}'
     ],
     'border radius side H+V': [
-      'a{border-top-left-radius:1em / 1em}',
-      'a{border-top-left-radius:1em/1em}'
+      'a{border-top-left-radius:2em / 1em}',
+      'a{border-top-left-radius:2em/1em}'
     ],
     'border radius expanded H+V': [
       'a{border-radius:1em 1em 1em 1em / 2em 2em 2em 2em}',