Skip to content

Commit e6a9b28

Browse files
committed
Replace hasOwnProperty with the more robust "has" package
1 parent fb7d4d3 commit e6a9b28

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

factoryWithTypeCheckers.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
'use strict';
99

1010
var assign = require('object-assign');
11+
var has = require('has');
1112

1213
var ReactPropTypesSecret = require('./lib/ReactPropTypesSecret');
1314
var checkPropTypes = require('./checkPropTypes');
@@ -318,7 +319,7 @@ module.exports = function(isValidElement, throwOnDirectAccess) {
318319
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
319320
}
320321
for (var key in propValue) {
321-
if (Object.prototype.hasOwnProperty.call(propValue, key)) {
322+
if (has(propValue, key)) {
322323
var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
323324
if (error instanceof Error) {
324325
return error;

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
"homepage": "https://facebook.github.io/react/",
2727
"dependencies": {
2828
"loose-envify": "^1.3.1",
29-
"object-assign": "^4.1.1"
29+
"object-assign": "^4.1.1",
30+
"has": "^1.0.1"
3031
},
3132
"scripts": {
3233
"test": "jest",

yarn.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1239,7 +1239,7 @@ has-flag@^1.0.0:
12391239
version "1.0.0"
12401240
resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-1.0.0.tgz#9d9e793165ce017a00f00418c43f942a7b1d11fa"
12411241

1242-
has@^1.0.0:
1242+
has@^1.0.0, has@^1.0.1:
12431243
version "1.0.1"
12441244
resolved "https://registry.yarnpkg.com/has/-/has-1.0.1.tgz#8461733f538b0837c9361e39a9ab9e9704dc2f28"
12451245
dependencies:

0 commit comments

Comments
 (0)