mirror of
https://github.com/zebrajr/react.git
synced 2026-01-15 12:15:22 +00:00
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:
@@ -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(
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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,
|
||||
|
||||
2
packages/react-dom/src/shared/DOMProperty.js
vendored
2
packages/react-dom/src/shared/DOMProperty.js
vendored
@@ -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 = {};
|
||||
|
||||
|
||||
@@ -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]) {
|
||||
|
||||
@@ -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 + ']*$');
|
||||
|
||||
@@ -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>,
|
||||
|
||||
@@ -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>,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
12
packages/shared/hasOwnProperty.js
Normal file
12
packages/shared/hasOwnProperty.js
Normal 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;
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user