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

Function validateProperty

code/event-handlers/public/app.js:15066–15109  ·  view source on GitHub ↗
(tagName, name)

Source from the content-addressed store, hash-verified

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

Callers 1

warnInvalidARIAPropsFunction · 0.70

Calls 2

warningFunction · 0.85
getStackAddendumFunction · 0.70

Tested by

no test coverage detected