+[3.0.1 / 2014-xx-xx](https://github.com/jakubpawlowicz/clean-css/compare/v3.0.0...v3.0.1)
+==================
+
+* Fixed issue [#411](https://github.com/GoalSmashers/clean-css/issues/411) - properties and important comments.
+
[3.0.0 / 2014-12-18](https://github.com/jakubpawlowicz/clean-css/compare/v2.2.22...v3.0.0)
==================
};
Rebuilder.prototype.rebuildValue = function (list, separator) {
- var lastEscaped = false;
+ var escaped = 0;
for (var i = 0, l = list.length; i < l; i++) {
var el = list[i];
if (el.value.indexOf('__ESCAPED_') === 0) {
- if (!lastEscaped)
- this.output.pop();
this.store(el);
- lastEscaped = true;
+ escaped++;
+
+ if (i === l - 1 && escaped > 0)
+ this.output.splice(this.output.length - escaped - 1, 1);
} else {
this.store(el);
this.store(i < l - 1 ? separator : '');
- lastEscaped = false;
+ escaped = 0;
}
}
};
function valueRebuilder(list, separator) {
var merged = '';
- var lastEscaped = false;
for (var i = 0, l = list.length; i < l; i++) {
var el = list[i];
if (el.value.indexOf('__ESCAPED_') === 0) {
- merged = (lastEscaped ? merged : merged.substring(0, merged.length - 1)) + el.value;
- lastEscaped = true;
+ merged += el.value;
+
+ if (i === l - 1) {
+ var lastSemicolonAt = merged.lastIndexOf(';');
+ merged = merged.substring(0, lastSemicolonAt) + merged.substring(lastSemicolonAt + 1);
+ }
} else {
merged += list[i].value + (i < l - 1 ? separator : '');
- lastEscaped = false;
}
}
''
],
'important after value': [
- 'div{color:red!important;/*!comment*/}',
- 'div{color:red!important/*!comment*/}'
+ 'div{color:red;/*!comment*/}',
+ 'div{color:red/*!comment*/}'
+ ],
+ 'important between values': [
+ 'div{color:red;/*!comment*/display:block}',
+ 'div{color:red;/*!comment*/display:block}'
],
'two important after value': [
- 'div{color:red!important;/*!1*//*!2*/}',
- 'div{color:red!important/*!1*//*!2*/}'
+ 'div{color:red;/*!1*//*!2*/}',
+ 'div{color:red/*!1*//*!2*/}'
]
}),
'escaping': cssContext({
assert.equal(minified.styles, 'div{color:red!important/*!comment*/}');
}
},
+ 'important comment between properties': {
+ 'topic': new CleanCSS({ sourceMap: true }).minify('div { color: #f00 !important; /*!comment*/; display: block }'),
+ 'has right output': function (errors, minified) {
+ assert.equal(minified.styles, 'div{color:red!important;/*!comment*/display:block}');
+ }
+ },
'important comments after a property': {
'topic': new CleanCSS({ sourceMap: true }).minify('div { color: #f00 !important; /*!1*//*!2*/ }'),
'has right output': function (errors, minified) {