Fixes #232 - edge case in non-adjacent selectors merging.
authorJakub Pawlowicz <jakub@goalsmashers.com>
Fri, 7 Feb 2014 21:07:24 +0000 (21:07 +0000)
committerJakub Pawlowicz <jakub@goalsmashers.com>
Fri, 7 Feb 2014 21:12:17 +0000 (21:12 +0000)
Gets rid of an edge case when non-adjacent selectors merging can lead to incorrect overridding of properties.

History.md
lib/selectors/optimizer.js
test/data/issue-232-min.css [new file with mode: 0644]
test/data/issue-232.css [new file with mode: 0644]

index 170d30d..6fc4f88 100644 (file)
 * Fixed issue [#229](https://github.com/GoalSmashers/clean-css/issues/229) - improved processing of fraction numbers.
 * Fixed issue [#230](https://github.com/GoalSmashers/clean-css/issues/230) - better handling of zero values.
 
+[2.0.8 / 2014-xx-xx (UNRELEASED)](https://github.com/GoalSmashers/clean-css/compare/v2.0.7...v2.0.8)
+==================
+
+* Fixed issue [#232](https://github.com/GoalSmashers/clean-css/issues/232) - edge case in non-adjacent selectors merging.
+
 [2.0.7 / 2014-01-16](https://github.com/GoalSmashers/clean-css/compare/v2.0.6...v2.0.7)
 ==================
 
index 256baa6..09f2b31 100644 (file)
@@ -104,7 +104,7 @@ module.exports = function Optimizer(data, context, options) {
         continue;
 
       selectors = selector.indexOf(',') > 0 ?
-        [selector].concat(selector.split(',')) :
+        selector.split(',').concat(selector) :
         [selector];
 
       for (var j = 0, m = selectors.length; j < m; j++) {
diff --git a/test/data/issue-232-min.css b/test/data/issue-232-min.css
new file mode 100644 (file)
index 0000000..fab8e6b
--- /dev/null
@@ -0,0 +1,2 @@
+.bar{padding:0}
+.bug-selector,.bug-selector1{background:#000 url(images/b-toolbar.gif);background:linear-gradient(#5e6081,#353340)}
diff --git a/test/data/issue-232.css b/test/data/issue-232.css
new file mode 100644 (file)
index 0000000..f734a83
--- /dev/null
@@ -0,0 +1,17 @@
+.bug-selector,
+.bug-selector1
+{
+  background: red;
+}
+
+.bar
+{
+  padding: 0;
+}
+
+.bug-selector,
+.bug-selector1
+{
+  background: black url('images/b-toolbar.gif');
+  background: linear-gradient(#5e6081, #353340);
+}