Skip to content

Commit 4d490eb

Browse files
mhamrahalexander-fenster
authored andcommitted
Use Object.hasOwnProperty instead of prototype (#1233)
1 parent de230ab commit 4d490eb

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/encoder.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ function encoder(mtype) {
4646
// Map fields
4747
if (field.map) {
4848
gen
49-
("if(%s!=null&&m.hasOwnProperty(%j)){", ref, field.name) // !== undefined && !== null
49+
("if(%s!=null&&Object.hasOwnProperty.call(m,%j)){", ref, field.name) // !== undefined && !== null
5050
("for(var ks=Object.keys(%s),i=0;i<ks.length;++i){", ref)
5151
("w.uint32(%i).fork().uint32(%i).%s(ks[i])", (field.id << 3 | 2) >>> 0, 8 | types.mapKey[field.keyType], field.keyType);
5252
if (wireType === undefined) gen
@@ -84,7 +84,7 @@ function encoder(mtype) {
8484
// Non-repeated
8585
} else {
8686
if (field.optional) gen
87-
("if(%s!=null&&m.hasOwnProperty(%j))", ref, field.name); // !== undefined && !== null
87+
("if(%s!=null&&Object.hasOwnProperty.call(m,%j))", ref, field.name); // !== undefined && !== null
8888

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

0 commit comments

Comments
 (0)