Commit dcc8ffd9 authored by Lian Duan's avatar Lian Duan Committed by Paul Yang

Fixed JS parsing of default map values (#6394)

parent cb58738d
...@@ -465,11 +465,15 @@ jspb.Map.prototype.serializeBinary = function( ...@@ -465,11 +465,15 @@ jspb.Map.prototype.serializeBinary = function(
* entries with unset keys is required for maps to be backwards compatible * entries with unset keys is required for maps to be backwards compatible
* with the repeated message representation described here: goo.gl/zuoLAC * with the repeated message representation described here: goo.gl/zuoLAC
* *
* @param {V=} opt_defaultValue
* The default value for the type of map values.
*
*/ */
jspb.Map.deserializeBinary = function(map, reader, keyReaderFn, valueReaderFn, jspb.Map.deserializeBinary = function(map, reader, keyReaderFn, valueReaderFn,
opt_valueReaderCallback, opt_defaultKey) { opt_valueReaderCallback, opt_defaultKey,
opt_defaultValue) {
var key = opt_defaultKey; var key = opt_defaultKey;
var value = undefined; var value = opt_defaultValue;
while (reader.nextField()) { while (reader.nextField()) {
if (reader.isEndGroup()) { if (reader.isEndGroup()) {
......
...@@ -3142,6 +3142,7 @@ void Generator::GenerateClassDeserializeBinaryField( ...@@ -3142,6 +3142,7 @@ void Generator::GenerateClassDeserializeBinaryField(
printer->Print(", null"); printer->Print(", null");
} }
printer->Print(", $defaultKey$", "defaultKey", JSFieldDefault(key_field)); printer->Print(", $defaultKey$", "defaultKey", JSFieldDefault(key_field));
printer->Print(", $defaultValue$", "defaultValue", JSFieldDefault(value_field));
printer->Print(");\n"); printer->Print(");\n");
printer->Print(" });\n"); printer->Print(" });\n");
} else { } else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment