浏览代码

fix debug.dump

Nikolai Vavilov 9 年之前
父节点
当前提交
73e0b49272
共有 1 个文件被更改,包括 4 次插入2 次删除
  1. 4 2
      js/debug.js

+ 4 - 2
js/debug.js

@@ -94,8 +94,10 @@ jspb.debug.dump_ = function(thing) {
     var match = /^get([A-Z]\w*)/.exec(name);
     var match = /^get([A-Z]\w*)/.exec(name);
     if (match && name != 'getExtension' &&
     if (match && name != 'getExtension' &&
         name != 'getJsPbMessageId') {
         name != 'getJsPbMessageId') {
-      var val = thing[name]();
-      if (val != null) {
+      var has = 'has' + match[1];
+      if (!thing[has] || thing[has]())
+      {
+        var val = thing[name]();
         object[jspb.debug.formatFieldName_(match[1])] = jspb.debug.dump_(val);
         object[jspb.debug.formatFieldName_(match[1])] = jspb.debug.dump_(val);
       }
       }
     }
     }