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()
This commit is contained in:
lamo2k123
2017-04-26 20:30:38 +01:00
committed by Dan Abramov
parent 805105b2d5
commit 1ba5336e32
6 changed files with 5 additions and 9 deletions
@@ -28,12 +28,11 @@ import type {Fiber} from 'ReactFiber';
function isNative(fn) {
// Based on isNative() from Lodash
var funcToString = Function.prototype.toString;
var hasOwnProperty = Object.prototype.hasOwnProperty;
var reIsNative = RegExp(
'^' +
funcToString
// Take an example native function source for comparison
.call(hasOwnProperty)
.call(Object.prototype.hasOwnProperty)
// Strip regex characters so we can use it for regex
.replace(/[\\^$.*+?()[\]{}|]/g, '\\$&')
// Remove hasOwnProperty from the template to make it generic
@@ -10,8 +10,6 @@
* @flow
*/
/* global hasOwnProperty:true */
'use strict';
var CSSPropertyOperations = require('CSSPropertyOperations');
@@ -8,6 +8,7 @@
*
* @emails react-core
*/
'use strict';
var React = require('react');
@@ -9,8 +9,6 @@
* @providesModule ReactDOMComponent
*/
/* global hasOwnProperty:true */
'use strict';
var AutoFocusUtils = require('AutoFocusUtils');
@@ -358,10 +356,9 @@ var voidElementTags = Object.assign(
var VALID_TAG_REGEX = /^[a-zA-Z][a-zA-Z:_\.\-\d]*$/; // Simplified subset
var validatedTagCache = {};
var hasOwnProperty = {}.hasOwnProperty;
function validateDangerousTag(tag) {
if (!hasOwnProperty.call(validatedTagCache, tag)) {
if (!validatedTagCache.hasOwnProperty(tag)) {
invariant(VALID_TAG_REGEX.test(tag), 'Invalid tag: %s', tag);
validatedTagCache[tag] = true;
}
@@ -9,6 +9,7 @@
* @providesModule ReactNativeBaseComponent
* @flow
*/
'use strict';
var NativeMethodsMixin = require('NativeMethodsMixin');
@@ -80,7 +80,7 @@ describe('ReactTestRenderer', () => {
// $$typeof should not be enumerable.
for (var key in object) {
if (Object.prototype.hasOwnProperty.call(object, key)) {
if (object.hasOwnProperty(key)) {
expect(key).not.toBe('$$typeof');
}
}