Makes multival operations idempotent.
authorJakub Pawlowicz <contact@jakubpawlowicz.com>
Mon, 25 Aug 2014 10:33:34 +0000 (11:33 +0100)
committerJakub Pawlowicz <contact@jakubpawlowicz.com>
Mon, 25 Aug 2014 14:14:25 +0000 (15:14 +0100)
History.md
lib/properties/processable.js

index 56152be..bc54729 100644 (file)
@@ -1,4 +1,10 @@
+[2.2.14 / 2014-xx-xx](https://github.com/jakubpawlowicz/clean-css/compare/v2.2.13...v2.2.14)
+==================
+
+* Makes multival operations idempotent.
+
 [2.2.13 / 2014-08-12](https://github.com/jakubpawlowicz/clean-css/compare/v2.2.12...v2.2.13)
+
 ==================
 
 * Fixed issue [#337](https://github.com/jakubpawlowicz/clean-css/issues/337) - handling component importance.
index edb3a00..95280b5 100644 (file)
@@ -483,15 +483,18 @@ module.exports = (function () {
         var mergedValues = [];
         var firstProcessed;
         for (i = 0; i < partsCount; i++) {
+          var newTokens = [];
           for (var k = 0, n = merged[i].length; k < n; k++) {
-            tokens[k].value = merged[i][k];
+            var newToken = tokens[k].clone();
+            newToken.value = merged[i][k];
+            newTokens.push(newToken);
           }
 
           var meta = {
             partsCount: partsCount,
             position: i
           };
-          var processed = assembleFunction(prop, tokens, isImportant, meta);
+          var processed = assembleFunction(prop, newTokens, isImportant, meta);
           mergedValues.push(processed.value);
 
           if (!firstProcessed)
@@ -549,9 +552,12 @@ module.exports = (function () {
     },
     borderRadius: function (prop, tokens, isImportant) {
       var verticalTokens = [];
+      var newTokens = [];
 
       for (var i = 0, l = tokens.length; i < l; i++) {
         var token = tokens[i];
+        var newToken = token.clone();
+        newTokens.push(newToken);
         if (!Array.isArray(token.value))
           continue;
 
@@ -563,10 +569,10 @@ module.exports = (function () {
           });
         }
 
-        token.value = token.value[0];
+        newToken.value = token.value[0];
       }
 
-      var result = putTogether.takeCareOfInherit(putTogether.fourUnits)(prop, tokens, isImportant);
+      var result = putTogether.takeCareOfInherit(putTogether.fourUnits)(prop, newTokens, isImportant);
       if (verticalTokens.length > 0) {
         var verticalResult = putTogether.takeCareOfInherit(putTogether.fourUnits)(prop, verticalTokens, isImportant);
         if (result.value != verticalResult.value)