* Requires Node.js 4.0+ to run.
+[3.4.9 / 2016-xx-xx](https://github.com/jakubpawlowicz/clean-css/compare/v3.4.8...3.4)
+==================
+
+* Fixed issue [#693](https://github.com/jakubpawlowicz/clean-css/issues/693) - restructuring edge case.
+
[3.4.8 / 2015-11-13](https://github.com/jakubpawlowicz/clean-css/compare/v3.4.7...v3.4.8)
==================
var stringifySelectors = require('../stringifier/one-time').selectors;
var cleanUpSelectorDuplicates = require('./clean-up').selectorDuplicates;
var isSpecial = require('./is-special');
+var cloneArray = require('../utils/clone-array');
function naturalSorter(a, b) {
return a > b;
}
+function cloneAndMergeSelectors(propertyA, propertyB) {
+ var cloned = cloneArray(propertyA);
+ cloned[5] = cloned[5].concat(propertyB[5]);
+
+ return cloned;
+}
+
function restructure(tokens, options) {
var movableTokens = {};
var movedProperties = [];
var token = tokens[i];
var isSelector;
var j, k, m;
+ var samePropertyAt;
if (token[0] == 'selector') {
isSelector = true;
}
}
- if (!movedSameProperty)
+ if (!movedSameProperty) {
movedSameProperty = property[0] == movedProperty[0] && property[1] == movedProperty[1];
+
+ if (movedSameProperty) {
+ samePropertyAt = k;
+ }
+ }
}
if (!isSelector || unmovableInCurrentToken.indexOf(j) > -1)
movableTokens[key] = movableTokens[key] || [];
movableTokens[key].push(token);
- if (!movedSameProperty)
+ if (movedSameProperty) {
+ movedProperties[samePropertyAt] = cloneAndMergeSelectors(movedProperties[samePropertyAt], property);
+ } else {
movedProperties.push(property);
+ }
}
movedToBeDropped = movedToBeDropped.sort(naturalSorter);
'.one{overflow:hidden;border-right:1px solid;border-color:#d4d4d4}.one:last-child{border-right:0}.two{overflow:hidden;border-right:1px solid;border-color:#d4d4d4}',
'.one,.two{overflow:hidden}.one{border-right:1px solid;border-color:#d4d4d4}.one:last-child{border-right:0}.two{border-right:1px solid;border-color:#d4d4d4}'
],
+ 'multiple - over redefined property': [
+ 'a,div{text-decoration:none}a{text-decoration:underline;color:#00f}p{text-decoration:underline}',
+ 'a,div{text-decoration:none}a,p{text-decoration:underline}a{color:#00f}'
+ ],
'granular two level deep': [
'.one{border:1px solid red;border-right-width:0}.two{border:1px solid red}',
'.one{border:1px solid red;border-right-width:0}.two{border:1px solid red}'