Fixed dot properties not optimizing unicode identifiers. Signed-off-by: Justin Lau...
authorJustin Lau <justin@tclau.com>
Sun, 5 May 2013 18:45:41 +0000 (02:45 +0800)
committerMihai Bazon <mihai@bazon.net>
Tue, 7 May 2013 11:20:19 +0000 (14:20 +0300)
lib/compress.js
lib/parse.js

index 623fe45..992d78f 100644 (file)
@@ -1962,8 +1962,8 @@ merge(Compressor.prototype, {
         var prop = self.property;
         if (prop instanceof AST_String && compressor.option("properties")) {
             prop = prop.getValue();
-            if (is_identifier(prop)
-                || (compressor.option("screw_ie8") && /^[a-z_$][a-z0-9_$]*$/i.test(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 da39b5b..b368720 100644 (file)
@@ -167,6 +167,14 @@ function is_identifier_char(ch) {
     ;
 };
 
+function is_identifier_string(str){
+    for (var i = str.length; --i >= 0;) {
+        if (!is_identifier_char(str.charAt(i)))
+            return false;
+    }
+    return true;
+};
+
 function parse_js_number(num) {
     if (RE_HEX_NUMBER.test(num)) {
         return parseInt(num.substr(2), 16);