Fixes #410 - handling comments in advanced optimizations.
authorJakub Pawlowicz <contact@jakubpawlowicz.com>
Fri, 19 Dec 2014 21:00:45 +0000 (21:00 +0000)
committerJakub Pawlowicz <contact@jakubpawlowicz.com>
Fri, 19 Dec 2014 21:00:45 +0000 (21:00 +0000)
History.md
lib/properties/optimizer.js
test/integration-test.js

index 5d309eb..3a829fe 100644 (file)
@@ -1,6 +1,7 @@
 [3.0.1 / 2014-xx-xx](https://github.com/jakubpawlowicz/clean-css/compare/v3.0.0...v3.0.1)
 ==================
 
+* Fixed issue [#410](https://github.com/GoalSmashers/clean-css/issues/410) - advanced merging and comments.
 * Fixed issue [#411](https://github.com/GoalSmashers/clean-css/issues/411) - properties and important comments.
 
 [3.0.0 / 2014-12-18](https://github.com/jakubpawlowicz/clean-css/compare/v2.2.22...v3.0.0)
index 22e604d..5e604cb 100644 (file)
@@ -183,7 +183,7 @@ module.exports = function Optimizer(options, context) {
       // e.g. a{display:inline-block;display:-moz-inline-box}
       // however if `mergeablePosition` yields true then the rule does not apply
       // (e.g merging two adjacent selectors: `a{display:block}a{display:block}`)
-      if (aggressiveMerging && _property != lastProperty || mergeablePosition(i)) {
+      if (aggressiveMerging && property !== '' && _property != lastProperty || mergeablePosition(i)) {
         while (true) {
           toOverridePosition = properties.indexOf(_property, toOverridePosition);
           if (toOverridePosition == -1)
index 19c9c45..bbef782 100644 (file)
@@ -304,6 +304,10 @@ vows.describe('integration tests').addBatch({
       'div{color:red;/*!comment*/display:block}',
       'div{color:red;/*!comment*/display:block}'
     ],
+    'important between and after values': [
+      'div{color:red;/*!comment1*/display:block;/*!comment2*/}',
+      'div{color:red;/*!comment1*/display:block/*!comment2*/}'
+    ],
     'two important after value': [
       'div{color:red;/*!1*//*!2*/}',
       'div{color:red/*!1*//*!2*/}'