Completely remove Object.prototype.hasOwnProperty.call() (#7853)
* Avoid directly calling hasOwnProperty * correct use hasOwnProperty * added eslint rules `no-prototype-builtins` http://eslint.org/docs/rules/no-prototype-builtins * single style hasOwnProperty * added file info /* global hasOwnProperty:true */ * added file info /* global hasOwnProperty:true */ * fixed no-prototype-builtins after merge * yarn run prettier fixed * remove src/addons * return space after * * remove /* global hasOwnProperty:true */ * Removed using Object.prototype.hasOwnProperty.call() * yarn run prettier fixed * Removed using Object.prototype.hasOwnProperty.call()
lamo2k123 committed
Apr 26, 2017 at 22:30 UTC
48479438a3a380002fae1f2c5ae803d51aef372d
6 files changed
+5
-9
src/isomorphic/hooks/ReactComponentTreeHook.js
+1
-2
@@ -28,12 +28,11 @@ import type {Fiber} from 'ReactFiber';
28
function isNative(fn) {
29
// Based on isNative() from Lodash
30
var funcToString = Function.prototype.toString;
31
- var hasOwnProperty = Object.prototype.hasOwnProperty;
31
var reIsNative = RegExp(
32
'^' +
33
funcToString
34
// Take an example native function source for comparison
36
- .call(hasOwnProperty)
35
+ .call(Object.prototype.hasOwnProperty)
36
// Strip regex characters so we can use it for regex
37
.replace(/[\\^$.*+?()[\]{}|]/g, '\\$&')
38
// Remove hasOwnProperty from the template to make it generic
src/renderers/dom/fiber/ReactDOMFiberComponent.js
-2
@@ -10,8 +10,6 @@
10
* @flow
11
*/
12
13
-/* global hasOwnProperty:true */
14
-
13
'use strict';
14
15
var CSSPropertyOperations = require('CSSPropertyOperations');
src/renderers/dom/shared/__tests__/inputValueTracking-test.js
+1
@@ -8,6 +8,7 @@
8
*
9
* @emails react-core
10
*/
11
+
12
'use strict';
13
14
var React = require('react');
src/renderers/dom/stack/client/ReactDOMComponent.js
+1
-4
@@ -9,8 +9,6 @@
9
* @providesModule ReactDOMComponent
10
*/
11
12
-/* global hasOwnProperty:true */
13
-
12
'use strict';
13
14
var AutoFocusUtils = require('AutoFocusUtils');
@@ -358,10 +356,9 @@ var voidElementTags = Object.assign(
356
357
var VALID_TAG_REGEX = /^[a-zA-Z][a-zA-Z:_\.\-\d]*$/; // Simplified subset
358
var validatedTagCache = {};
361
-var hasOwnProperty = {}.hasOwnProperty;
359
360
function validateDangerousTag(tag) {
364
- if (!hasOwnProperty.call(validatedTagCache, tag)) {
361
+ if (!validatedTagCache.hasOwnProperty(tag)) {
362
invariant(VALID_TAG_REGEX.test(tag), 'Invalid tag: %s', tag);
363
validatedTagCache[tag] = true;
364
}
src/renderers/native/ReactNativeBaseComponent.js
+1
@@ -9,6 +9,7 @@
9
* @providesModule ReactNativeBaseComponent
10
* @flow
11
*/
12
+
13
'use strict';
14
15
var NativeMethodsMixin = require('NativeMethodsMixin');
src/renderers/testing/__tests__/ReactTestRenderer-test.js
+1
-1
@@ -80,7 +80,7 @@ describe('ReactTestRenderer', () => {
80
81
// $$typeof should not be enumerable.
82
for (var key in object) {
83
- if (Object.prototype.hasOwnProperty.call(object, key)) {
83
+ if (object.hasOwnProperty(key)) {
84
expect(key).not.toBe('$$typeof');
85
}
86
}