Fixed JS parsing of default map values (#6394)

This commit is contained in:
Lian Duan 2019-07-25 01:32:21 +02:00 committed by Paul Yang
parent cb58738de2
commit dcc8ffd9c6
2 changed files with 7 additions and 2 deletions

View File

@ -465,11 +465,15 @@ jspb.Map.prototype.serializeBinary = function(
* entries with unset keys is required for maps to be backwards compatible
* 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,
opt_valueReaderCallback, opt_defaultKey) {
opt_valueReaderCallback, opt_defaultKey,
opt_defaultValue) {
var key = opt_defaultKey;
var value = undefined;
var value = opt_defaultValue;
while (reader.nextField()) {
if (reader.isEndGroup()) {

View File

@ -3142,6 +3142,7 @@ void Generator::GenerateClassDeserializeBinaryField(
printer->Print(", null");
}
printer->Print(", $defaultKey$", "defaultKey", JSFieldDefault(key_field));
printer->Print(", $defaultValue$", "defaultValue", JSFieldDefault(value_field));
printer->Print(");\n");
printer->Print(" });\n");
} else {