ReactDOMInvalidARIAHook.js — react Source File
Architecture documentation for ReactDOMInvalidARIAHook.js, a javascript file in the react codebase. 3 imports, 2 dependents.
Entity Profile
Dependency Diagram
graph LR c1dc9c2d_185d_8161_e658_7c3c75929b15["ReactDOMInvalidARIAHook.js"] 36fcaad4_7e57_5971_700b_f932b635486a["isAttributeNameSafe.js"] c1dc9c2d_185d_8161_e658_7c3c75929b15 --> 36fcaad4_7e57_5971_700b_f932b635486a 597484b2_9524_2cec_2a6f_a214a62bc3c3["validAriaProperties.js"] c1dc9c2d_185d_8161_e658_7c3c75929b15 --> 597484b2_9524_2cec_2a6f_a214a62bc3c3 a413acd5_7541_e904_f255_d4dd9b5e5bc1["hasOwnProperty"] c1dc9c2d_185d_8161_e658_7c3c75929b15 --> a413acd5_7541_e904_f255_d4dd9b5e5bc1 1e990658_7cea_75be_1f24_2399bdf9f15b["ReactDOMComponent.js"] 1e990658_7cea_75be_1f24_2399bdf9f15b --> c1dc9c2d_185d_8161_e658_7c3c75929b15 4ae326e8_2c2e_2843_d5a5_16edbddd103a["ReactFizzConfigDOM.js"] 4ae326e8_2c2e_2843_d5a5_16edbddd103a --> c1dc9c2d_185d_8161_e658_7c3c75929b15 style c1dc9c2d_185d_8161_e658_7c3c75929b15 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
/**
* 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.
*/
import {ATTRIBUTE_NAME_CHAR} from './isAttributeNameSafe';
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 + ']*$');
function validateProperty(tagName, name) {
if (__DEV__) {
if (hasOwnProperty.call(warnedProperties, name) && warnedProperties[name]) {
return true;
}
if (rARIACamel.test(name)) {
const ariaName = 'aria-' + name.slice(4).toLowerCase();
const correctName = validAriaProperties.hasOwnProperty(ariaName)
? ariaName
: null;
// If this is an aria-* attribute, but is not listed in the known DOM
// DOM properties, then it is an invalid aria-* attribute.
if (correctName == null) {
console.error(
'Invalid ARIA attribute `%s`. ARIA attributes follow the pattern aria-* and must be lowercase.',
name,
);
warnedProperties[name] = true;
return true;
}
// aria-* attributes should be lowercase; suggest the lowercase version.
if (name !== correctName) {
console.error(
'Invalid ARIA attribute `%s`. Did you mean `%s`?',
name,
correctName,
);
warnedProperties[name] = true;
return true;
}
}
if (rARIA.test(name)) {
const lowerCasedName = name.toLowerCase();
const standardName = validAriaProperties.hasOwnProperty(lowerCasedName)
? lowerCasedName
: null;
// If this is an aria-* attribute, but is not listed in the known DOM
// DOM properties, then it is an invalid aria-* attribute.
if (standardName == null) {
warnedProperties[name] = true;
return false;
}
// aria-* attributes should be lowercase; suggest the lowercase version.
if (name !== standardName) {
console.error(
'Unknown ARIA attribute `%s`. Did you mean `%s`?',
name,
standardName,
);
warnedProperties[name] = true;
return true;
}
}
}
return true;
}
export function validateProperties(type, props) {
if (__DEV__) {
const invalidProps = [];
for (const key in props) {
const isValid = validateProperty(type, key);
if (!isValid) {
invalidProps.push(key);
}
}
const unknownPropString = invalidProps
.map(prop => '`' + prop + '`')
.join(', ');
if (invalidProps.length === 1) {
console.error(
'Invalid aria prop %s on <%s> tag. ' +
'For details, see https://react.dev/link/invalid-aria-props',
unknownPropString,
type,
);
} else if (invalidProps.length > 1) {
console.error(
'Invalid aria props %s on <%s> tag. ' +
'For details, see https://react.dev/link/invalid-aria-props',
unknownPropString,
type,
);
}
}
}
Domain
Subdomains
Functions
Dependencies
- hasOwnProperty
- isAttributeNameSafe.js
- validAriaProperties.js
Imported By
Source
Frequently Asked Questions
What does ReactDOMInvalidARIAHook.js do?
ReactDOMInvalidARIAHook.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain, Validation subdomain.
What functions are defined in ReactDOMInvalidARIAHook.js?
ReactDOMInvalidARIAHook.js defines 2 function(s): validateProperties, validateProperty.
What does ReactDOMInvalidARIAHook.js depend on?
ReactDOMInvalidARIAHook.js imports 3 module(s): hasOwnProperty, isAttributeNameSafe.js, validAriaProperties.js.
What files import ReactDOMInvalidARIAHook.js?
ReactDOMInvalidARIAHook.js is imported by 2 file(s): ReactDOMComponent.js, ReactFizzConfigDOM.js.
Where is ReactDOMInvalidARIAHook.js in the architecture?
ReactDOMInvalidARIAHook.js is located at packages/react-dom-bindings/src/shared/ReactDOMInvalidARIAHook.js (domain: BabelCompiler, subdomain: Validation, directory: packages/react-dom-bindings/src/shared).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free