diff --git a/js/lib/beautify-html.js b/js/lib/beautify-html.js index bf87f9808..efc4061c0 100644 --- a/js/lib/beautify-html.js +++ b/js/lib/beautify-html.js @@ -128,7 +128,7 @@ wrap_attributes = (options.wrap_attributes === undefined) ? 'auto' : options.wrap_attributes; wrap_attributes_indent_size = (options.wrap_attributes_indent_size === undefined) ? indent_size : parseInt(options.wrap_attributes_indent_size, 10) || indent_size; end_with_newline = (options.end_with_newline === undefined) ? false : options.end_with_newline; - extra_liners = Array.isArray(options.extra_liners) ? + extra_liners = (typeof options.extra_liners == 'object') && options.extra_liners ? options.extra_liners.concat() : (typeof options.extra_liners === 'string') ? options.extra_liners.split(',') : 'head,body,/html'.split(','); eol = options.eol ? options.eol : '\n'; @@ -435,15 +435,15 @@ if (tag_complete.indexOf(' ') !== -1) { //if there's whitespace, thats where the tag name ends tag_index = tag_complete.indexOf(' '); - } else if (tag_complete[0] === '{') { + } else if (tag_complete.charAt(0) === '{') { tag_index = tag_complete.indexOf('}'); } else { //otherwise go with the tag ending tag_index = tag_complete.indexOf('>'); } - if (tag_complete[0] === '<' || !indent_handlebars) { + if (tag_complete.charAt(0) === '<' || !indent_handlebars) { tag_offset = 1; } else { - tag_offset = tag_complete[2] === '#' ? 3 : 2; + tag_offset = tag_complete.charAt(2) === '#' ? 3 : 2; } var tag_check = tag_complete.substring(tag_offset, tag_index).toLowerCase(); if (tag_complete.charAt(tag_complete.length - 2) === '/' || @@ -451,7 +451,7 @@ if (!peek) { this.tag_type = 'SINGLE'; } - } else if (indent_handlebars && tag_complete[0] === '{' && tag_check === 'else') { + } else if (indent_handlebars && tag_complete.charAt(0) === '{' && tag_check === 'else') { if (!peek) { this.indent_to_tag('if'); this.tag_type = 'HANDLEBARS_ELSE'; @@ -531,7 +531,7 @@ comment += input_char; // only need to check for the delimiter if the last chars match - if (comment[comment.length - 1] === delimiter[delimiter.length - 1] && + if (comment.charAt(comment.length - 1) === delimiter.charAt(delimiter.length - 1) && comment.indexOf(delimiter) !== -1) { break; } @@ -608,7 +608,7 @@ this.line_char_count++; space = true; - if (indent_handlebars && input_char === '{' && content.length && content[content.length - 2] === '{') { + if (indent_handlebars && input_char === '{' && content.length && content.charAt(content.length - 2) === '{') { // Handlebars expressions in strings should also be unformatted. content += this.get_unformatted('}}'); // These expressions are opaque. Ignore delimiters found in them. @@ -747,7 +747,7 @@ } if (text && text !== '') { - if (text.length > 1 && text[text.length - 1] === '\n') { + if (text.length > 1 && text.charAt(text.length - 1) === '\n') { // unformatted tags can grab newlines as their last character this.output.push(text.slice(0, -1)); this.print_newline(false, this.output); @@ -869,8 +869,11 @@ if (_beautifier) { // call the Beautifier if avaliable - var child_options = JSON.parse(JSON.stringify(options)); - child_options.eol = '\n'; + var Child_options = function() { + this.eol = '\n'; + }; + Child_options.prototype = options; + var child_options = new Child_options(); text = _beautifier(text.replace(/^\s*/, indentation), child_options); } else { // simply indent the string otherwise diff --git a/js/test/beautify-css-tests.js b/js/test/beautify-css-tests.js index e955bf359..e89d3dc29 100644 --- a/js/test/beautify-css-tests.js +++ b/js/test/beautify-css-tests.js @@ -14,7 +14,7 @@ function run_css_tests(test_obj, Urlencoded, js_beautify, html_beautify, css_bea break_chained_methods: false, selector_separator: '\n', end_with_newline: false, - newline_between_rules: true, + newline_between_rules: true }; function test_css_beautifier(input) diff --git a/test/template/node-css.mustache b/test/template/node-css.mustache index 522ffc8a6..f806a9150 100644 --- a/test/template/node-css.mustache +++ b/test/template/node-css.mustache @@ -14,7 +14,7 @@ function run_css_tests(test_obj, Urlencoded, js_beautify, html_beautify, css_bea break_chained_methods: false, selector_separator: '\n', end_with_newline: false, - newline_between_rules: true, + newline_between_rules: true }; function test_css_beautifier(input)