==================
* Fixed issue [#660](https://github.com/jakubpawlowicz/clean-css/issues/660) - !important token overriding.
+* Fixed issue [#662](https://github.com/jakubpawlowicz/clean-css/issues/662) - !important selector reducing.
[3.4.1 / 2015-08-27](https://github.com/jakubpawlowicz/clean-css/compare/v3.4.0...v3.4.1)
==================
var stringifyBody = require('../stringifier/one-time').body;
var stringifySelectors = require('../stringifier/one-time').selectors;
var isSpecial = require('./is-special');
+var cloneArray = require('../utils/clone-array');
function reduceNonAdjacent(tokens, options, validator) {
var candidates = {};
var where = data[j].where;
var token = tokens[where];
+ var clonedBody = cloneArray(token[2]);
- bodies = bodies.concat(token[2]);
- bodiesAsList.push(token[2]);
+ bodies = bodies.concat(clonedBody);
+ bodiesAsList.push(clonedBody);
processedTokens.push(where);
}
--- /dev/null
+function cloneArray(array) {
+ var cloned = array.slice(0);
+
+ for (var i = 0, l = cloned.length; i < l; i++) {
+ if (Array.isArray(cloned[i]))
+ cloned[i] = cloneArray(cloned[i]);
+ }
+
+ return cloned;
+}
+
+module.exports = cloneArray;
'over a @media block': [
'.one{color:red;margin:0}@media{.two{font-weight:700}}.one{font-size:13px}',
'.one{color:red;margin:0;font-size:13px}@media{.two{font-weight:700}}'
+ ],
+ '!important values': [
+ '.one,.two{margin:0!important}.one{margin:1px!important}',
+ '.one,.two{margin:0!important}.one{margin:1px!important}'
]
})
)
--- /dev/null
+var vows = require('vows');
+var assert = require('assert');
+var cloneArray = require('../../lib/utils/clone-array');
+
+vows.describe(cloneArray)
+ .addBatch({
+ 'one level': {
+ 'topic': [1, 2, 3],
+ 'not equal': function (topic) {
+ assert.notEqual(topic, cloneArray(topic));
+ },
+ 'deep equal': function (topic) {
+ assert.deepEqual(topic, cloneArray(topic));
+ }
+ },
+ 'two levels': {
+ 'topic': [[1], [2], [3]],
+ 'not equal': function (topic) {
+ assert.notEqual(topic[0], cloneArray(topic)[0]);
+ assert.notEqual(topic[1], cloneArray(topic)[1]);
+ assert.notEqual(topic[2], cloneArray(topic)[2]);
+ },
+ 'deep equal': function (topic) {
+ assert.deepEqual(topic, cloneArray(topic));
+ }
+ },
+ 'mixed levels': {
+ 'topic': [[1], 2, 3],
+ 'not equal': function (topic) {
+ assert.notEqual(topic[0], cloneArray(topic)[0]);
+ assert.equal(topic[1], cloneArray(topic)[1]);
+ assert.equal(topic[2], cloneArray(topic)[2]);
+ },
+ 'deep equal': function (topic) {
+ assert.deepEqual(topic, cloneArray(topic));
+ }
+ }
+ })
+ .export(module);