diff --git a/beautify/beautify-css.js b/beautify/beautify-css.js index c9f021e7..5e45c2b6 100644 --- a/beautify/beautify-css.js +++ b/beautify/beautify-css.js @@ -62,19 +62,12 @@ (function() { function css_beautify(source_text, options) { - function defaultOption(opt, defaultValue) { - return opt === undefined ? defaultValue : opt; - } options = options || {}; var indentSize = options.indent_size || 4; var indentCharacter = options.indent_char || ' '; - var selectorSeparatorNewline = defaultOption(options.selector_separator_newline, true); - var end_with_newline = defaultOption(options.end_with_newline, false); - var newline_between_rules = defaultOption(options.newline_between_rules, true); - var newline_between_properties = defaultOption(options.newline_between_properties, true); - var newline_before_open_brace = defaultOption(options.newline_before_open_brace, false); - var newline_after_open_brace = defaultOption(options.newline_after_open_brace, true); - var newline_before_close_brace = defaultOption(options.newline_before_close_brace, true); + var selectorSeparatorNewline = (options.selector_separator_newline === undefined) ? true : options.selector_separator_newline; + var end_with_newline = (options.end_with_newline === undefined) ? false : options.end_with_newline; + var newline_between_rules = (options.newline_between_rules === undefined) ? true : options.newline_between_rules; // compatibility if (typeof indentSize === "string") { @@ -203,12 +196,12 @@ var print = {}; print["{"] = function(ch) { - newline_before_open_brace ? output.push('\n') : print.singleSpace(); + print.singleSpace(); output.push(ch); - newline_after_open_brace ? print.newLine() : print.singleSpace(); + print.newLine(); }; print["}"] = function(ch) { - newline_before_close_brace ? print.newLine() : print.singleSpace(); + print.newLine(); output.push(ch); print.newLine(); }; @@ -363,7 +356,7 @@ output.push(eatString(ch)); } else if (ch === ';') { output.push(ch); - newline_between_properties ? print.newLine() : print.singleSpace(); + print.newLine(); } else if (ch === '(') { // may be a url if (lookBack("url")) { output.push(ch);