* Since advanced processing tokenizes data we can rebuild it without empty elements.
[2.1.0 / 2013-xx-xx (UNRELEASED)](https://github.com/GoalSmashers/clean-css/compare/v2.0.0...HEAD)
==================
+* Skips empty removal if advanced processing is enabled.
* Fixed issue [#161](https://github.com/GoalSmashers/clean-css/issues/161) - improves tokenizer performance.
* Fixed issue [#163](https://github.com/GoalSmashers/clean-css/issues/163) - round pixels to 2nd decimal place.
* Fixed issue [#165](https://github.com/GoalSmashers/clean-css/issues/165) - extra space after trailing parenthesis.
data.replace(new RegExp('@charset [^;]+;(' + lineBreak + ')?', 'g'), '').trim();
});
- replace(function removeEmptySelectors() {
- data = new EmptyRemoval(data).process();
- });
+ if (options.noAdvanced) {
+ replace(function removeEmptySelectors() {
+ data = new EmptyRemoval(data).process();
+ });
+ }
// trim spaces at beginning and end
data = data.trim();
};
var rebuild = function(tokens) {
- return (Array.isArray(tokens) ? tokens : [tokens])
- .map(function(token) {
- if (typeof token == 'string')
- return token;
-
- if (token.block)
- return token.block + '{' + rebuild(token.body) + '}';
- else
- return token.selector + '{' + token.body + '}';
- })
- .join(options.keepBreaks ? options.lineBreak : '');
+ var rebuilt = [];
+
+ tokens = Array.isArray(tokens) ? tokens : [tokens];
+ for (var i = 0, l = tokens.length; i < l; i++) {
+ var token = tokens[i];
+
+ if (typeof token == 'string') {
+ rebuilt.push(token);
+ continue;
+ }
+
+ var name = token.block || token.selector;
+ var body = token.block ? rebuild(token.body) : token.body;
+
+ if (body.length > 0)
+ rebuilt.push(name + '{' + body + '}');
+ }
+
+ return rebuilt.join(options.keepBreaks ? options.lineBreak : '');
};
return {
''
]
}),
+ 'empty with disabled advanced optimizations': cssContext({
+ 'selector': [
+ 'a{}p{}',
+ ''
+ ],
+ 'media': [
+ '@media screen{}',
+ ''
+ ]
+ }, { noAdvanced: true }),
'@import': cssContext({
'empty': [
"@import url();",