MCPcopy Create free account
hub / github.com/reactjs/react-rails / validateProperty

Function validateProperty

lib/assets/react-source/development/react.js:9038–9086  ·  view source on GitHub ↗
(tagName, name)

Source from the content-addressed store, hash-verified

9036 var hasOwnProperty$1 = Object.prototype.hasOwnProperty;
9037
9038 function validateProperty(tagName, name) {
9039 {
9040 if (hasOwnProperty$1.call(warnedProperties, name) && warnedProperties[name]) {
9041 return true;
9042 }
9043
9044 if (rARIACamel.test(name)) {
9045 var ariaName = 'aria-' + name.slice(4).toLowerCase();
9046 var correctName = ariaProperties.hasOwnProperty(ariaName) ? ariaName : null; // If this is an aria-* attribute, but is not listed in the known DOM
9047 // DOM properties, then it is an invalid aria-* attribute.
9048
9049 if (correctName == null) {
9050 error('Invalid ARIA attribute `%s`. ARIA attributes follow the pattern aria-* and must be lowercase.', name);
9051
9052 warnedProperties[name] = true;
9053 return true;
9054 } // aria-* attributes should be lowercase; suggest the lowercase version.
9055
9056
9057 if (name !== correctName) {
9058 error('Invalid ARIA attribute `%s`. Did you mean `%s`?', name, correctName);
9059
9060 warnedProperties[name] = true;
9061 return true;
9062 }
9063 }
9064
9065 if (rARIA.test(name)) {
9066 var lowerCasedName = name.toLowerCase();
9067 var standardName = ariaProperties.hasOwnProperty(lowerCasedName) ? lowerCasedName : null; // If this is an aria-* attribute, but is not listed in the known DOM
9068 // DOM properties, then it is an invalid aria-* attribute.
9069
9070 if (standardName == null) {
9071 warnedProperties[name] = true;
9072 return false;
9073 } // aria-* attributes should be lowercase; suggest the lowercase version.
9074
9075
9076 if (name !== standardName) {
9077 error('Unknown ARIA attribute `%s`. Did you mean `%s`?', name, standardName);
9078
9079 warnedProperties[name] = true;
9080 return true;
9081 }
9082 }
9083 }
9084
9085 return true;
9086 }
9087
9088 function warnInvalidARIAProps(type, props) {
9089 {

Callers 1

warnInvalidARIAPropsFunction · 0.70

Calls 1

errorFunction · 0.70

Tested by

no test coverage detected