From dfd9fc59e0c3ce336ac9db1cb0a2321c63ff5bb5 Mon Sep 17 00:00:00 2001 From: Jakub Pawlowicz Date: Fri, 7 Feb 2014 21:07:24 +0000 Subject: [PATCH] Fixes #232 - edge case in non-adjacent selectors merging. Gets rid of an edge case when non-adjacent selectors merging can lead to incorrect overridding of properties. --- History.md | 5 +++++ lib/selectors/optimizer.js | 2 +- test/data/issue-232-min.css | 2 ++ test/data/issue-232.css | 17 +++++++++++++++++ 4 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 test/data/issue-232-min.css create mode 100644 test/data/issue-232.css diff --git a/History.md b/History.md index 170d30d0..6fc4f88d 100644 --- a/History.md +++ b/History.md @@ -20,6 +20,11 @@ * 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) ================== diff --git a/lib/selectors/optimizer.js b/lib/selectors/optimizer.js index 256baa67..09f2b311 100644 --- a/lib/selectors/optimizer.js +++ b/lib/selectors/optimizer.js @@ -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 index 00000000..fab8e6bb --- /dev/null +++ b/test/data/issue-232-min.css @@ -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 index 00000000..f734a834 --- /dev/null +++ b/test/data/issue-232.css @@ -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); +} -- 2.34.1