/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import type {HostContext, HostContextDev} from './ReactFiberConfigDOM'; import {HostContextNamespaceNone} from './ReactFiberConfigDOM'; import { registrationNameDependencies, possibleRegistrationNames, } from '../events/EventRegistry'; import {canUseDOM} from 'shared/ExecutionEnvironment'; import {checkHtmlStringCoercion} from 'shared/CheckStringCoercion'; import {checkAttributeStringCoercion} from 'shared/CheckStringCoercion'; import {checkControlledValueProps} from '../shared/ReactControlledValuePropTypes'; import { getValueForAttribute, getValueForAttributeOnCustomComponent, setValueForPropertyOnCustomComponent, setValueForKnownAttribute, setValueForAttribute, setValueForNamespacedAttribute, } from './DOMPropertyOperations'; import { validateInputProps, initInput, updateInput, restoreControlledInputState, } from './ReactDOMInput'; import {validateOptionProps} from './ReactDOMOption'; import { validateSelectProps, initSelect, restoreControlledSelectState, updateSelect, } from './ReactDOMSelect'; import { validateTextareaProps, initTextarea, updateTextarea, restoreControlledTextareaState, } from './ReactDOMTextarea'; import {validateTextNesting} from './validateDOMNesting'; import {track} from './inputValueTracking'; import setInnerHTML from './setInnerHTML'; import setTextContent from './setTextContent'; import { createDangerousStringForStyles, setValueForStyles, } from './CSSPropertyOperations'; import {SVG_NAMESPACE, MATH_NAMESPACE} from './DOMNamespaces'; import isCustomElement from '../shared/isCustomElement'; import getAttributeAlias from '../shared/getAttributeAlias'; import possibleStandardNames from '../shared/possibleStandardNames'; import {validateProperties as validateARIAProperties} from '../shared/ReactDOMInvalidARIAHook'; import {validateProperties as validateInputProperties} from '../shared/ReactDOMNullInputValuePropHook'; import {validateProperties as validateUnknownProperties} from '../shared/ReactDOMUnknownPropertyHook'; import sanitizeURL from '../shared/sanitizeURL'; import { enableBigIntSupport, enableCustomElementPropertySupport, disableIEWorkarounds, enableTrustedTypesIntegration, enableFilterEmptyStringAttributesDOM, enableNewBooleanProps, } from 'shared/ReactFeatureFlags'; import { mediaEventTypes, listenToNonDelegatedEvent, } from '../events/DOMPluginEventSystem'; let didWarnControlledToUncontrolled = false; let didWarnUncontrolledToControlled = false; let didWarnFormActionType = false; let didWarnFormActionName = false; let didWarnFormActionTarget = false; let didWarnFormActionMethod = false; let didWarnForNewBooleanPropsWithEmptyValue: {[string]: boolean}; let canDiffStyleForHydrationWarning; if (__DEV__) { didWarnForNewBooleanPropsWithEmptyValue = {}; // IE 11 parses & normalizes the style attribute as opposed to other // browsers. It adds spaces and sorts the properties in some // non-alphabetical order. Handling that would require sorting CSS // properties in the client & server versions or applying // `expectedStyle` to a temporary DOM node to read its `style` attribute // normalized. Since it only affects IE, we're skipping style warnings // in that browser completely in favor of doing all that work. // See https://github.com/facebook/react/issues/11807 canDiffStyleForHydrationWarning = disableIEWorkarounds || (canUseDOM && !document.documentMode); } function validatePropertiesInDevelopment(type: string, props: any) { if (__DEV__) { validateARIAProperties(type, props); validateInputProperties(type, props); validateUnknownProperties(type, props, { registrationNameDependencies, possibleRegistrationNames, }); if ( props.contentEditable && !props.suppressContentEditableWarning && props.children != null ) { console.error( 'A component is `contentEditable` and contains `children` managed by ' + 'React. It is now your responsibility to guarantee that none of ' + 'those nodes are unexpectedly modified or duplicated. This is ' + 'probably not intentional.', ); } } } function validateFormActionInDevelopment( tag: string, key: string, value: mixed, props: any, ) { if (__DEV__) { if (value == null) { return; } if (tag === 'form') { if (key === 'formAction') { console.error( 'You can only pass the formAction prop to or