diff options
author | Mihai Bazon <mihai@bazon.net> | 2013-05-14 10:41:28 +0300 |
---|---|---|
committer | Mihai Bazon <mihai@bazon.net> | 2013-05-14 10:42:34 +0300 |
commit | d56ebd7d7b8de0b46ce203b580df28d76fa16692 (patch) | |
tree | 403409d74658fbaf0ea6fdef24f10d0dfc94bf8d | |
parent | 3edfe7d0ee644a5ea0383fe02152b4f7f578cfcb (diff) | |
download | tracifyjs-d56ebd7d7b8de0b46ce203b580df28d76fa16692.tar.gz tracifyjs-d56ebd7d7b8de0b46ce203b580df28d76fa16692.zip |
Fix a["1_1"]
Close #204
-rw-r--r-- | lib/compress.js | 4 | ||||
-rw-r--r-- | lib/parse.js | 1 | ||||
-rw-r--r-- | test/compress/properties.js | 2 |
3 files changed, 5 insertions, 2 deletions
diff --git a/lib/compress.js b/lib/compress.js index c94af7d0..24cdc026 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -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 diff --git a/lib/parse.js b/lib/parse.js index c8c5d0a0..a687495b 100644 --- a/lib/parse.js +++ b/lib/parse.js @@ -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; diff --git a/test/compress/properties.js b/test/compress/properties.js index f490fd86..85045961 100644 --- a/test/compress/properties.js +++ b/test/compress/properties.js @@ -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"; } } |