[2.1.0 / 2013-xx-xx (UNRELEASED)](https://github.com/GoalSmashers/clean-css/compare/v2.0.0...HEAD)
==================
+* Adds an optional callback to minify method.
* Deprecates --selectors-merge-mode / selectorsMergeMode in favor to --compatibility / compatibility.
* Skips empty removal if advanced processing is enabled.
* Fixed issue [#160](https://github.com/GoalSmashers/clean-css/issues/160) - re-runs optimizer until a clean pass.
this.lineBreak = process.platform == 'win32' ? '\r\n' : '\n';
};
-CleanCSS.prototype.minify = function(data) {
+CleanCSS.prototype.minify = function(data, callback) {
var startedAt;
var stats = this.stats;
var options = this.options;
stats.minifiedSize = data.length;
}
- return data;
+ return callback ?
+ callback.call(this, this.context.errors.length > 0 ? this.context.errors : null, data) :
+ data;
};
delete CleanCSS.prototype.foo;
}
},
+ 'with callback passed and no errors': {
+ topic: function() {
+ new CleanCSS().minify('a{color:#f00}', this.callback);
+ },
+ 'should correctly set context': function() {
+ assert.equal(true, this instanceof CleanCSS);
+ },
+ 'should yield no error': function(errors, minified) {
+ /* jshint unused: false */
+ assert.equal(errors, null);
+ },
+ 'should yield minified data': function(errors, minified) {
+ assert.equal(minified, 'a{color:red}');
+ }
+ },
+ 'with callback passed and one error': {
+ topic: function() {
+ new CleanCSS().minify('@import "missing.css";', this.callback);
+ },
+ 'should yield no error and minify': function(errors, minified) {
+ /* jshint unused: false */
+ assert.equal(errors.length, 1);
+ }
+ },
'no debug': {
topic: function() {
var minifier = new CleanCSS();