MCPcopy Create free account
hub / github.com/krasimir/react-in-patterns / validateProperty

Function validateProperty

code/controlled-uncontrolled/public/app.js:15060–15103  ·  view source on GitHub ↗
(tagName, name)

Source from the content-addressed store, hash-verified

15058}
15059
15060function validateProperty(tagName, name) {
15061 if (hasOwnProperty.call(warnedProperties, name) && warnedProperties[name]) {
15062 return true;
15063 }
15064
15065 if (rARIACamel.test(name)) {
15066 var ariaName = 'aria-' + name.slice(4).toLowerCase();
15067 var correctName = ariaProperties.hasOwnProperty(ariaName) ? ariaName : null;
15068
15069 // If this is an aria-* attribute, but is not listed in the known DOM
15070 // DOM properties, then it is an invalid aria-* attribute.
15071 if (correctName == null) {
15072 warning(false, 'Invalid ARIA attribute `%s`. ARIA attributes follow the pattern aria-* and must be lowercase.%s', name, getStackAddendum());
15073 warnedProperties[name] = true;
15074 return true;
15075 }
15076 // aria-* attributes should be lowercase; suggest the lowercase version.
15077 if (name !== correctName) {
15078 warning(false, 'Invalid ARIA attribute `%s`. Did you mean `%s`?%s', name, correctName, getStackAddendum());
15079 warnedProperties[name] = true;
15080 return true;
15081 }
15082 }
15083
15084 if (rARIA.test(name)) {
15085 var lowerCasedName = name.toLowerCase();
15086 var standardName = ariaProperties.hasOwnProperty(lowerCasedName) ? lowerCasedName : null;
15087
15088 // If this is an aria-* attribute, but is not listed in the known DOM
15089 // DOM properties, then it is an invalid aria-* attribute.
15090 if (standardName == null) {
15091 warnedProperties[name] = true;
15092 return false;
15093 }
15094 // aria-* attributes should be lowercase; suggest the lowercase version.
15095 if (name !== standardName) {
15096 warning(false, 'Unknown ARIA attribute `%s`. Did you mean `%s`?%s', name, standardName, getStackAddendum());
15097 warnedProperties[name] = true;
15098 return true;
15099 }
15100 }
15101
15102 return true;
15103}
15104
15105function warnInvalidARIAProps(type, props) {
15106 var invalidProps = [];

Callers 1

warnInvalidARIAPropsFunction · 0.70

Calls 2

warningFunction · 0.85
getStackAddendumFunction · 0.70

Tested by

no test coverage detected