diff --git a/js/lib/beautify.js b/js/lib/beautify.js index a91e14ae..3cac9e06 100644 --- a/js/lib/beautify.js +++ b/js/lib/beautify.js @@ -176,6 +176,7 @@ opt.preserve_newlines = (options.preserve_newlines === undefined) ? true : options.preserve_newlines; opt.break_chained_methods = (options.break_chained_methods === undefined) ? false : options.break_chained_methods; opt.max_preserve_newlines = (options.max_preserve_newlines === undefined) ? 0 : parseInt(options.max_preserve_newlines, 10); + opt.space_in_paren = (options.space_in_paren === undefined) ? false : options.space_in_paren; opt.jslint_happy = (options.jslint_happy === undefined) ? false : options.jslint_happy; opt.keep_array_indentation = (options.keep_array_indentation === undefined) ? false : options.keep_array_indentation; opt.space_before_conditional= (options.space_before_conditional === undefined) ? true : options.space_before_conditional; @@ -866,7 +867,7 @@ } set_mode(MODE.Expression); print_token(); - if (options.space_in_paren) { + if (opt.space_in_paren) { output_space_before_token = true; } return; @@ -923,7 +924,7 @@ } } print_token(); - if (options.space_in_paren) { + if (opt.space_in_paren) { output_space_before_token = true; } if (token_text === '[') { @@ -943,7 +944,7 @@ print_newline(); } restore_mode(); - if (options.space_in_paren) { + if (opt.space_in_paren) { output_space_before_token = true; } print_token(); diff --git a/js/test/beautify-tests.js b/js/test/beautify-tests.js index bc3511d6..f8ba529f 100755 --- a/js/test/beautify-tests.js +++ b/js/test/beautify-tests.js @@ -906,9 +906,9 @@ function run_beautifier_tests(test_obj, Urlencoded, js_beautify) 'a = 1;\n\n\n\n\n\n\n\nb = 2;'); // Test the option to have spaces within parens - test_fragment('if(p) foo(a,b)', 'if (p) foo(a, b)'); + bt('if(p) foo(a,b)', 'if (p) foo(a, b)'); opts.space_in_paren = true - test_fragment('if(p) foo(a,b)', 'if ( p ) foo( a, b )'); + bt('if(p) foo(a,b)', 'if ( p ) foo( a, b )'); opts.space_in_paren = false; Urlencoded.run_tests(sanitytest); diff --git a/python/jsbeautifier/tests/testjsbeautifier.py b/python/jsbeautifier/tests/testjsbeautifier.py index 98f60db7..519fb2d4 100644 --- a/python/jsbeautifier/tests/testjsbeautifier.py +++ b/python/jsbeautifier/tests/testjsbeautifier.py @@ -841,9 +841,9 @@ class TestJSBeautifier(unittest.TestCase): 'a = 1;\n\n\n\n\n\n\n\nb = 2;'); # Test the option to have spaces within parens - test_fragment('if(p) foo(a,b)', 'if (p) foo(a, b)'); + bt('if(p) foo(a,b)', 'if (p) foo(a, b)'); self.options.space_in_paren = True - test_fragment('if(p) foo(a,b)', 'if ( p ) foo( a, b )'); + bt('if(p) foo(a,b)', 'if ( p ) foo( a, b )'); self.options.space_in_paren = False