Fix a["1_1"]
authorMihai Bazon <mihai@bazon.net>
Tue, 14 May 2013 07:41:28 +0000 (10:41 +0300)
committerMihai Bazon <mihai@bazon.net>
Tue, 14 May 2013 07:42:34 +0000 (10:42 +0300)
Close #204

lib/compress.js
lib/parse.js
test/compress/properties.js

index c94af7d..24cdc02 100644 (file)
@@ -1965,8 +1965,8 @@ 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 ((compressor.option("screw_ie8") && RESERVED_WORDS(prop))
+                || (!(RESERVED_WORDS(prop)) && is_identifier_string(prop))) {
                 return make_node(AST_Dot, self, {
                     expression : self.expression,
                     property   : prop
index c8c5d0a..a687495 100644 (file)
@@ -170,6 +170,7 @@ function is_identifier_char(ch) {
 function is_identifier_string(str){
     var i = str.length;
     if (i == 0) return false;
+    if (is_digit(str.charCodeAt(0))) return false;
     while (--i >= 0) {
         if (!is_identifier_char(str.charAt(i)))
             return false;
index f490fd8..8504596 100644 (file)
@@ -20,6 +20,7 @@ dot_properties: {
         a["*"] = "asterisk";
         a["\u0EB3"] = "unicode";
         a[""] = "whitespace";
+        a["1_1"] = "foo";
     }
     expect: {
         a.foo = "bar";
@@ -27,6 +28,7 @@ dot_properties: {
         a["*"] = "asterisk";
         a.\u0EB3 = "unicode";
         a[""] = "whitespace";
+        a["1_1"] = "foo";
     }
 }