Skip to content

Commit

Permalink
Fixed JS parsing of default map values
Browse files Browse the repository at this point in the history
w
  • Loading branch information
chemhack committed Jul 17, 2019
1 parent 744e799 commit b06c35b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 6 additions & 2 deletions js/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
1 change: 1 addition & 0 deletions src/google/protobuf/compiler/js/js_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3161,6 +3161,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 {
Expand Down

0 comments on commit b06c35b

Please sign in to comment.