From: Michael Ficarra Date: Mon, 19 Aug 2013 00:45:06 +0000 (-0500) Subject: fixes #259: don't unnecessarily quote object properties when --screw-ie8 X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=d9ad3c7c;p=UglifyJS.git fixes #259: don't unnecessarily quote object properties when --screw-ie8 --- diff --git a/bin/uglifyjs b/bin/uglifyjs index cad29ee0..7a4f6224 100755 --- a/bin/uglifyjs +++ b/bin/uglifyjs @@ -129,11 +129,6 @@ if (ARGS.d) { if (COMPRESS) COMPRESS.global_defs = getOptions("d"); } -if (ARGS.screw_ie8) { - if (COMPRESS) COMPRESS.screw_ie8 = true; - if (MANGLE) MANGLE.screw_ie8 = true; -} - if (ARGS.r) { if (MANGLE) MANGLE.except = ARGS.r.replace(/^\s+|\s+$/g).split(/\s*,+\s*/); } @@ -142,6 +137,12 @@ var OUTPUT_OPTIONS = { beautify: BEAUTIFY ? true : false }; +if (ARGS.screw_ie8) { + if (COMPRESS) COMPRESS.screw_ie8 = true; + if (MANGLE) MANGLE.screw_ie8 = true; + OUTPUT_OPTIONS.screw_ie8 = true; +} + if (BEAUTIFY) UglifyJS.merge(OUTPUT_OPTIONS, BEAUTIFY); diff --git a/lib/compress.js b/lib/compress.js index 3bf9f672..8dfbc72b 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -2005,8 +2005,7 @@ merge(Compressor.prototype, { var prop = self.property; if (prop instanceof AST_String && compressor.option("properties")) { prop = prop.getValue(); - if ((compressor.option("screw_ie8") && RESERVED_WORDS(prop)) - || (!(RESERVED_WORDS(prop)) && is_identifier_string(prop))) { + if (RESERVED_WORDS(prop) ? compressor.option("screw_ie8") : is_identifier_string(prop)) { return make_node(AST_Dot, self, { expression : self.expression, property : prop diff --git a/lib/output.js b/lib/output.js index 90589a2d..6d0dac5a 100644 --- a/lib/output.js +++ b/lib/output.js @@ -54,13 +54,13 @@ function OutputStream(options) { inline_script : false, width : 80, max_line_len : 32000, - ie_proof : true, beautify : false, source_map : null, bracketize : false, semicolons : true, comments : false, preserve_line : false, + screw_ie8 : false, negate_iife : !(options && options.beautify), }, true); @@ -761,7 +761,7 @@ function OutputStream(options) { if (!self.body) return output.force_semicolon(); if (self.body instanceof AST_Do - && output.option("ie_proof")) { + && !output.option("screw_ie8")) { // https://github.com/mishoo/UglifyJS/issues/#issue/57 IE // croaks with "syntax error" on code like this: if (foo) // do ... while(cond); else ... we need block brackets @@ -1048,10 +1048,10 @@ function OutputStream(options) { && +key + "" == key) && parseFloat(key) >= 0) { output.print(make_num(key)); - } else if (!is_identifier(key)) { - output.print_string(key); - } else { + } else if (RESERVED_WORDS(key) ? output.option("screw_ie8") : is_identifier_string(key)) { output.print_name(key); + } else { + output.print_string(key); } output.colon(); self.value.print(output);