Skip to content

Commit

Permalink
Use Object.hasOwnProperty instead of prototype (#1233)
Browse files Browse the repository at this point in the history
  • Loading branch information
mhamrah authored and alexander-fenster committed Jun 24, 2019
1 parent de230ab commit 4d490eb
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/encoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function encoder(mtype) {
// Map fields
if (field.map) {
gen
("if(%s!=null&&m.hasOwnProperty(%j)){", ref, field.name) // !== undefined && !== null
("if(%s!=null&&Object.hasOwnProperty.call(m,%j)){", ref, field.name) // !== undefined && !== null
("for(var ks=Object.keys(%s),i=0;i<ks.length;++i){", ref)
("w.uint32(%i).fork().uint32(%i).%s(ks[i])", (field.id << 3 | 2) >>> 0, 8 | types.mapKey[field.keyType], field.keyType);
if (wireType === undefined) gen
Expand Down Expand Up @@ -84,7 +84,7 @@ function encoder(mtype) {
// Non-repeated
} else {
if (field.optional) gen
("if(%s!=null&&m.hasOwnProperty(%j))", ref, field.name); // !== undefined && !== null
("if(%s!=null&&Object.hasOwnProperty.call(m,%j))", ref, field.name); // !== undefined && !== null

if (wireType === undefined)
genTypePartial(gen, field, index, ref);
Expand All @@ -97,4 +97,4 @@ function encoder(mtype) {
return gen
("return w");
/* eslint-enable no-unexpected-multiline, block-scoped-var, no-redeclare */
}
}

0 comments on commit 4d490eb

Please sign in to comment.