Skip to content

Commit 34e20b8

Browse files
shadowspawnljharb
authored andcommitted
[Robustness] rework isConstructorOrProto
- modify implementation of isConstructorOrProto to match main branch - call isConstructorOrProto on last key too
1 parent c0b2661 commit 34e20b8

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ function isNumber(x) {
77
}
88

99
function isConstructorOrProto(obj, key) {
10-
return key === 'constructor' && (typeof obj[key] === 'function' || key === '__proto__');
10+
return (key === 'constructor' && typeof obj[key] === 'function') || key === '__proto__';
1111
}
1212

1313
function hasKey(obj, keys) {
@@ -25,7 +25,7 @@ function setKey(obj, keys, value) {
2525
var key;
2626
for (var i = 0; i < keys.length - 1; i++) {
2727
key = keys[i];
28-
if (key === '__proto__' || isConstructorOrProto(o, key)) {
28+
if (isConstructorOrProto(o, key)) {
2929
return;
3030
}
3131
if (o[key] === undefined) { o[key] = {}; }
@@ -41,7 +41,7 @@ function setKey(obj, keys, value) {
4141
}
4242

4343
key = keys[keys.length - 1];
44-
if (key === '__proto__') { return; }
44+
if (isConstructorOrProto(o, key)) { return; }
4545
if (
4646
o === Object.prototype
4747
|| o === Number.prototype

0 commit comments

Comments
 (0)