Adds semicolonAfterLastProperty to format options and force keeping semicolon after last property, defaults to `false`.
indentBy: 0,
indentWith: IndentWith.Space,
spaces: spaces(false),
- wrapAt: false
+ wrapAt: false,
+ semicolonAfterLastProperty: false
};
var BEAUTIFY_ALIAS = 'beautify';
var store = context.store;
var token = tokens[position];
var isPropertyBlock = token[2][0] == Token.PROPERTY_BLOCK;
- var needsSemicolon = position < lastPropertyAt || isPropertyBlock;
+
+ var needsSemicolon;
+ if ( context.format ) {
+ if ( context.format.semicolonAfterLastProperty || isPropertyBlock ) {
+ needsSemicolon = true;
+ } else if ( position < lastPropertyAt ) {
+ needsSemicolon = true;
+ } else {
+ needsSemicolon = false;
+ }
+ } else {
+ needsSemicolon = position < lastPropertyAt || isPropertyBlock;
+ }
+
var isLast = position === lastPropertyAt;
switch (token[0]) {
'should give right output': function (minified) {
assert.equal(minified.styles, '.one{color:red}.three{background-image:url(test/fixtures/partials/extra/down.gif)}');
}
+ },
+ 'keeps trailing semicolons if option is set': {
+ 'topic': function() {
+ return new CleanCSS({format: { semicolonAfterLastProperty: true }}).minify('*{ font-size:12px; color:#ea7500; }');
+ },
+ 'should minify correctly': function (error, minified) {
+ assert.equal(minified.styles, '*{font-size:12px;color:#ea7500;}');
+ },
+ 'should raise no errors': function (error, minified) {
+ assert.isEmpty(minified.errors);
+ }
}
}).export(module);
beforeBlockBegins: false,
beforeValue: false
},
- wrapAt: false
+ wrapAt: false,
+ semicolonAfterLastProperty: false
});
}
},
beforeBlockBegins: false,
beforeValue: false
},
- wrapAt: false
+ wrapAt: false,
+ semicolonAfterLastProperty: false
});
}
},
beforeBlockBegins: false,
beforeValue: false
},
- wrapAt: false
+ wrapAt: false,
+ semicolonAfterLastProperty: false
});
}
},
beforeBlockBegins: false,
beforeValue: false
},
- wrapAt: false
+ wrapAt: false,
+ semicolonAfterLastProperty: false
});
}
},
beforeBlockBegins: false,
beforeValue: false
},
- wrapAt: false
+ wrapAt: false,
+ semicolonAfterLastProperty: false
});
}
},
beforeBlockBegins: false,
beforeValue: false
},
- wrapAt: 25
+ wrapAt: 25,
+ semicolonAfterLastProperty: false
});
}
},
beforeBlockBegins: false,
beforeValue: false
},
- wrapAt: false
+ wrapAt: false,
+ semicolonAfterLastProperty: false
});
}
},
beforeBlockBegins: true,
beforeValue: true
},
- wrapAt: false
+ wrapAt: false,
+ semicolonAfterLastProperty: false
});
}
},
beforeBlockBegins: false,
beforeValue: false
},
- wrapAt: false
+ wrapAt: false,
+ semicolonAfterLastProperty: false
});
}
}