THRIFT-1214 JavaScript constructor does not accept object properties
Patch: Henrique Mendonca


git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1138013 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/compiler/cpp/src/generate/t_js_generator.cc b/compiler/cpp/src/generate/t_js_generator.cc
index 8daaedf..7561b12 100644
--- a/compiler/cpp/src/generate/t_js_generator.cc
+++ b/compiler/cpp/src/generate/t_js_generator.cc
@@ -560,7 +560,7 @@
     out << indent() <<  "if (args) {" << endl;
 
     for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
-        out << indent() << indent() << "if (!args." << (*m_iter)->get_name() << ") {" << endl
+        out << indent() << indent() << "if (args." << (*m_iter)->get_name() << " !== undefined) {" << endl
             << indent() << indent() << indent() << "this." << (*m_iter)->get_name() << " = args." << (*m_iter)->get_name()  << ";" << endl
             << indent() << indent() << "}" << endl;
     }
diff --git a/lib/js/thrift.js b/lib/js/thrift.js
index f4e7235..8b1733e 100644
--- a/lib/js/thrift.js
+++ b/lib/js/thrift.js
@@ -460,7 +460,7 @@
                 map = ',' + map;
             }
 
-            if ( ! isNaN(k)) { k = '"' + k + '"'; } //json "keys" need to be strings
+            if (! isNaN(k)) { k = '"' + k + '"'; } //json "keys" need to be strings
             map = k + ':' + v + map;
         }
         map = '{' + map;