This commit is contained in:
Justin Lau 2013-05-05 11:48:50 -07:00
commit 8e1344e62c
3 changed files with 18 additions and 1 deletions

View File

@ -1962,7 +1962,8 @@ merge(Compressor.prototype, {
var prop = self.property; var prop = self.property;
if (prop instanceof AST_String && compressor.option("properties")) { if (prop instanceof AST_String && compressor.option("properties")) {
prop = prop.getValue(); prop = prop.getValue();
if (is_identifier(prop) || compressor.option("screw_ie8")) { if (compressor.option("screw_ie8") && RESERVED_WORDS(prop)
|| !(RESERVED_WORDS(prop)) && is_identifier_string(prop)) {
return make_node(AST_Dot, self, { return make_node(AST_Dot, self, {
expression : self.expression, expression : self.expression,
property : prop property : prop

View File

@ -167,6 +167,14 @@ function is_identifier_char(ch) {
; ;
}; };
function is_identifier_string(string){
for(var i in string) {
if(!is_identifier_char(string[i]))
return false;
}
return true;
}
function parse_js_number(num) { function parse_js_number(num) {
if (RE_HEX_NUMBER.test(num)) { if (RE_HEX_NUMBER.test(num)) {
return parseInt(num.substr(2), 16); return parseInt(num.substr(2), 16);

View File

@ -17,10 +17,14 @@ dot_properties: {
input: { input: {
a["foo"] = "bar"; a["foo"] = "bar";
a["if"] = "if"; a["if"] = "if";
a["*"] = "asterisk";
a["\u0EB3"] = "unicode";
} }
expect: { expect: {
a.foo = "bar"; a.foo = "bar";
a["if"] = "if"; a["if"] = "if";
a["*"] = "asterisk";
a.\u0EB3 = "unicode";
} }
} }
@ -32,9 +36,13 @@ dot_properties_es5: {
input: { input: {
a["foo"] = "bar"; a["foo"] = "bar";
a["if"] = "if"; a["if"] = "if";
a["*"] = "asterisk";
a["\u0EB3"] = "unicode";
} }
expect: { expect: {
a.foo = "bar"; a.foo = "bar";
a.if = "if"; a.if = "if";
a["*"] = "asterisk";
a.\u0EB3 = "unicode";
} }
} }