+[2.1.1 / 2014-xx-xx (UNRELEASED)](https://github.com/GoalSmashers/clean-css/compare/v2.1.0...v2.1.1)
+==================
+
+* Fixed issue [#241](https://github.com/GoalSmashers/clean-css/issues/241) - incorrect handling of :not() selectors.
+
[2.1.0 / 2014-02-13](https://github.com/GoalSmashers/clean-css/compare/v2.0.8...v2.1.0)
==================
var cleanUpSelector = function(selectors) {
var plain = [];
- selectors = selectors.split(',');
+ var cursor = 0;
+ var lastComma = 0;
+ var noBrackets = selectors.indexOf('(') == -1;
+ var withinBrackets = function(idx) {
+ if (noBrackets)
+ return false;
+
+ var previousOpening = selectors.lastIndexOf('(', idx);
+ var previousClosing = selectors.lastIndexOf(')', idx);
+
+ if (previousOpening == -1)
+ return false;
+ if (previousClosing > 0 && previousClosing < idx)
+ return false;
+
+ return true;
+ };
- for (var i = 0, l = selectors.length; i < l; i++) {
- var sel = selectors[i];
+ while (true) {
+ var nextComma = selectors.indexOf(',', cursor + 1);
+ var selector;
- if (plain.indexOf(sel) == -1)
- plain.push(sel);
+ if (nextComma === -1) {
+ nextComma = selectors.length;
+ } else if (withinBrackets(nextComma)) {
+ cursor = nextComma + 1;
+ continue;
+ }
+ selector = selectors.substring(lastComma, nextComma);
+ lastComma = cursor = nextComma + 1;
+
+ if (plain.indexOf(selector) == -1)
+ plain.push(selector);
+
+ if (nextComma === selectors.length)
+ break;
}
return plain.sort().join(',');