Remove redundant initial of hasOwnProperty (#21134)

* remove redundant initial of hasOwnProperty

* remove redundant initial of hasOwnProperty part 2

* remove redundant initial of hasOwnProperty part 3
This commit is contained in:
Behnam Mohammadi
2021-04-01 20:35:10 +04:30
committed by GitHub
parent 1cf9978d89
commit 2c9fef32db
15 changed files with 29 additions and 25 deletions

View File

@@ -13,6 +13,7 @@ import {
} from '../events/EventRegistry';
import {canUseDOM} from 'shared/ExecutionEnvironment';
import hasOwnProperty from 'shared/hasOwnProperty';
import {
getValueForAttribute,
@@ -443,7 +444,7 @@ export function createElement(
!isCustomComponentTag &&
Object.prototype.toString.call(domElement) ===
'[object HTMLUnknownElement]' &&
!Object.prototype.hasOwnProperty.call(warnedUnknownTags, type)
!hasOwnProperty.call(warnedUnknownTags, type)
) {
warnedUnknownTags[type] = true;
console.error(

View File

@@ -44,9 +44,9 @@ import warnValidStyle from '../shared/warnValidStyle';
import escapeTextForBrowser from './escapeTextForBrowser';
import hyphenateStyleName from '../shared/hyphenateStyleName';
import invariant from 'shared/invariant';
import hasOwnProperty from 'shared/hasOwnProperty';
import sanitizeURL from '../shared/sanitizeURL';
const hasOwnProperty = Object.prototype.hasOwnProperty;
const isArray = Array.isArray;
// Per response, global state that is not contextual to the rendering subtree.

View File

@@ -77,6 +77,7 @@ import warnValidStyle from '../shared/warnValidStyle';
import {validateProperties as validateARIAProperties} from '../shared/ReactDOMInvalidARIAHook';
import {validateProperties as validateInputProperties} from '../shared/ReactDOMNullInputValuePropHook';
import {validateProperties as validateUnknownProperties} from '../shared/ReactDOMUnknownPropertyHook';
import hasOwnProperty from 'shared/hasOwnProperty';
export type ServerOptions = {
identifierPrefix?: string,
@@ -340,7 +341,6 @@ function flattenOptionChildren(children: mixed): ?string {
return content;
}
const hasOwnProperty = Object.prototype.hasOwnProperty;
const STYLE = 'style';
const RESERVED_PROPS = {
children: null,

View File

@@ -8,6 +8,7 @@
*/
import {enableFilterEmptyStringAttributesDOM} from 'shared/ReactFeatureFlags';
import hasOwnProperty from 'shared/hasOwnProperty';
type PropertyType = 0 | 1 | 2 | 3 | 4 | 5 | 6;
@@ -67,7 +68,6 @@ export const VALID_ATTRIBUTE_NAME_REGEX = new RegExp(
'^[' + ATTRIBUTE_NAME_START_CHAR + '][' + ATTRIBUTE_NAME_CHAR + ']*$',
);
const hasOwnProperty = Object.prototype.hasOwnProperty;
const illegalAttributeNameCache = {};
const validatedAttributeNameCache = {};

View File

@@ -8,13 +8,12 @@
import {ATTRIBUTE_NAME_CHAR} from './DOMProperty';
import isCustomComponent from './isCustomComponent';
import validAriaProperties from './validAriaProperties';
import hasOwnProperty from 'shared/hasOwnProperty';
const warnedProperties = {};
const rARIA = new RegExp('^(aria)-[' + ATTRIBUTE_NAME_CHAR + ']*$');
const rARIACamel = new RegExp('^(aria)[A-Z][' + ATTRIBUTE_NAME_CHAR + ']*$');
const hasOwnProperty = Object.prototype.hasOwnProperty;
function validateProperty(tagName, name) {
if (__DEV__) {
if (hasOwnProperty.call(warnedProperties, name) && warnedProperties[name]) {

View File

@@ -14,12 +14,12 @@ import {
} from './DOMProperty';
import isCustomComponent from './isCustomComponent';
import possibleStandardNames from './possibleStandardNames';
import hasOwnProperty from 'shared/hasOwnProperty';
let validateProperty = () => {};
if (__DEV__) {
const warnedProperties = {};
const hasOwnProperty = Object.prototype.hasOwnProperty;
const EVENT_NAME_REGEX = /^on./;
const INVALID_EVENT_NAME_REGEX = /^on[^A-Z]/;
const rARIA = new RegExp('^(aria)-[' + ATTRIBUTE_NAME_CHAR + ']*$');

View File

@@ -13,6 +13,8 @@ import type {Request, ReactModel} from 'react-server/src/ReactFlightServer';
import JSResourceReference from 'JSResourceReference';
import hasOwnProperty from 'shared/hasOwnProperty';
export type ModuleReference<T> = JSResourceReference<T>;
import type {
@@ -72,8 +74,6 @@ export function processErrorChunk(
];
}
const hasOwnProperty = Object.prototype.hasOwnProperty;
function convertModelToJSON(
request: Request,
parent: {+[key: string]: ReactModel} | $ReadOnlyArray<ReactModel>,

View File

@@ -10,7 +10,7 @@
import type {RowEncoding, JSONValue} from './ReactFlightNativeRelayProtocol';
import type {Request, ReactModel} from 'react-server/src/ReactFlightServer';
import hasOwnProperty from 'shared/hasOwnProperty';
import JSResourceReferenceImpl from 'JSResourceReferenceImpl';
export type ModuleReference<T> = JSResourceReferenceImpl<T>;
@@ -72,8 +72,6 @@ export function processErrorChunk(
];
}
const hasOwnProperty = Object.prototype.hasOwnProperty;
function convertModelToJSON(
request: Request,
parent: {+[key: string]: ReactModel} | $ReadOnlyArray<ReactModel>,

View File

@@ -8,11 +8,10 @@
import getComponentNameFromType from 'shared/getComponentNameFromType';
import invariant from 'shared/invariant';
import {REACT_ELEMENT_TYPE} from 'shared/ReactSymbols';
import hasOwnProperty from 'shared/hasOwnProperty';
import ReactCurrentOwner from './ReactCurrentOwner';
const hasOwnProperty = Object.prototype.hasOwnProperty;
const RESERVED_PROPS = {
key: true,
ref: true,

View File

@@ -33,6 +33,7 @@ import {
} from './ReactElement';
import {setExtraStackFrame} from './ReactDebugCurrentFrame';
import {describeUnknownElementTypeFrameInDEV} from 'shared/ReactComponentStackFrame';
import hasOwnProperty from 'shared/hasOwnProperty';
function setCurrentlyValidatingElement(element) {
if (__DEV__) {
@@ -56,8 +57,6 @@ if (__DEV__) {
propTypesMisspellWarningShown = false;
}
const hasOwnProperty = Object.prototype.hasOwnProperty;
function getDeclarationErrorAddendum() {
if (ReactCurrentOwner.current) {
const name = getComponentNameFromType(ReactCurrentOwner.current.type);

View File

@@ -7,13 +7,11 @@
import getComponentNameFromType from 'shared/getComponentNameFromType';
import ReactSharedInternals from 'shared/ReactSharedInternals';
import hasOwnProperty from 'shared/hasOwnProperty';
import {REACT_ELEMENT_TYPE} from 'shared/ReactSymbols';
const ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
const hasOwnProperty = Object.prototype.hasOwnProperty;
const RESERVED_PROPS = {
key: true,
ref: true,

View File

@@ -22,7 +22,7 @@ import {
REACT_ELEMENT_TYPE,
} from 'shared/ReactSymbols';
import {warnAboutSpreadingKeyToJSX} from 'shared/ReactFeatureFlags';
import hasOwnProperty from 'shared/hasOwnProperty';
import {jsxDEV} from './ReactJSXElement';
import {describeUnknownElementTypeFrameInDEV} from 'shared/ReactComponentStackFrame';
@@ -54,8 +54,6 @@ if (__DEV__) {
propTypesMisspellWarningShown = false;
}
const hasOwnProperty = Object.prototype.hasOwnProperty;
/**
* Verifies the object is a ReactElement.
* See https://reactjs.org/docs/react-api.html#isvalidelement

View File

@@ -12,6 +12,7 @@ const loggedTypeFailures = {};
import {describeUnknownElementTypeFrameInDEV} from 'shared/ReactComponentStackFrame';
import ReactSharedInternals from 'shared/ReactSharedInternals';
import hasOwnProperty from 'shared/hasOwnProperty';
const ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
@@ -40,7 +41,7 @@ export default function checkPropTypes(
): void {
if (__DEV__) {
// $FlowFixMe This is okay but Flow doesn't know it.
const has = Function.call.bind(Object.prototype.hasOwnProperty);
const has = Function.call.bind(hasOwnProperty);
for (const typeSpecName in typeSpecs) {
if (has(typeSpecs, typeSpecName)) {
let error;

View File

@@ -0,0 +1,12 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
const hasOwnProperty = Object.prototype.hasOwnProperty;
export default hasOwnProperty;

View File

@@ -8,8 +8,7 @@
*/
import is from './objectIs';
const hasOwnProperty = Object.prototype.hasOwnProperty;
import hasOwnProperty from './hasOwnProperty';
/**
* Performs equality by iterating through keys on an object and returning false