* Should be rather done on tokenization step. To be improved in 3.1.
* Fixed issue [#363](https://github.com/GoalSmashers/clean-css/issues/363) - `rem` units overriding `px`.
* Fixed issue [#373](https://github.com/GoalSmashers/clean-css/issues/373) - proper background shorthand merging.
* Fixed issue [#395](https://github.com/GoalSmashers/clean-css/issues/395) - unescaped brackets in data URIs.
+* Fixed issue [#398](https://github.com/GoalSmashers/clean-css/issues/398) - restoring important comments.
* Fixed issue [#400](https://github.com/GoalSmashers/clean-css/issues/400) - API to accept an array of filenames.
* Fixed issue [#403](https://github.com/GoalSmashers/clean-css/issues/403) - tracking input files in source maps.
* Fixed issue [#404](https://github.com/GoalSmashers/clean-css/issues/404) - no state sharing in API.
eligibleForCompacting = true;
// FIXME: the check should be gone with #396
- var property = tokens[i][0].indexOf('__ESCAPED_') === 0 ?
- tokens[i][0] :
+ var property = !tokens[i][0] && tokens[i][1].indexOf('__ESCAPED_') === 0 ?
+ tokens[i][1] :
tokens[i][0] + ':' + tokens[i][1];
tokenized.push({ value: property, metadata: tokens[i][4] });
list.push(property);
};
Rebuilder.prototype.rebuildValue = function (list, separator) {
+ var lastEscaped = false;
+
for (var i = 0, l = list.length; i < l; i++) {
- this.store(list[i]);
- this.store(i < l - 1 ? separator : '');
+ var el = list[i];
+
+ if (el.value.indexOf('__ESCAPED_') === 0) {
+ if (!lastEscaped)
+ this.output.pop();
+ this.store(el);
+ lastEscaped = true;
+ } else {
+ this.store(el);
+ this.store(i < l - 1 ? separator : '');
+ lastEscaped = false;
+ }
}
};
function valueRebuilder(list, separator) {
var merged = '';
+ var lastEscaped = false;
- for (var i = 0, l = list.length; i < l; i++)
- merged += list[i].value + (i < l - 1 ? separator : '');
+ 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;
+ } else {
+ merged += list[i].value + (i < l - 1 ? separator : '');
+ lastEscaped = false;
+ }
+ }
return merged;
}
'with quote marks': [
'/*"*//* */',
''
+ ],
+ 'important after value': [
+ 'div{color:red!important;/*!comment*/}',
+ 'div{color:red!important/*!comment*/}'
+ ],
+ 'two important after value': [
+ 'div{color:red!important;/*!1*//*!2*/}',
+ 'div{color:red!important/*!1*//*!2*/}'
]
}),
'escaping': cssContext({
}
}
})
+ .addBatch({
+ 'important comment after a property': {
+ 'topic': new CleanCSS({ sourceMap: true }).minify('div { color: #f00 !important; /*!comment*/ }'),
+ 'has right output': function (errors, minified) {
+ assert.equal(minified.styles, 'div{color:red!important/*!comment*/}');
+ }
+ },
+ 'important comments after a property': {
+ 'topic': new CleanCSS({ sourceMap: true }).minify('div { color: #f00 !important; /*!1*//*!2*/ }'),
+ 'has right output': function (errors, minified) {
+ assert.equal(minified.styles, 'div{color:red!important/*!1*//*!2*/}');
+ }
+ }
+ })
.export(module);