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

Function validateProperty

code/new-context-api/public/app.js:15097–15140  ·  view source on GitHub ↗
(tagName, name)

Source from the content-addressed store, hash-verified

15095}
15096
15097function validateProperty(tagName, name) {
15098 if (hasOwnProperty.call(warnedProperties, name) && warnedProperties[name]) {
15099 return true;
15100 }
15101
15102 if (rARIACamel.test(name)) {
15103 var ariaName = 'aria-' + name.slice(4).toLowerCase();
15104 var correctName = ariaProperties.hasOwnProperty(ariaName) ? ariaName : null;
15105
15106 // If this is an aria-* attribute, but is not listed in the known DOM
15107 // DOM properties, then it is an invalid aria-* attribute.
15108 if (correctName == null) {
15109 warning(false, 'Invalid ARIA attribute `%s`. ARIA attributes follow the pattern aria-* and must be lowercase.%s', name, getStackAddendum());
15110 warnedProperties[name] = true;
15111 return true;
15112 }
15113 // aria-* attributes should be lowercase; suggest the lowercase version.
15114 if (name !== correctName) {
15115 warning(false, 'Invalid ARIA attribute `%s`. Did you mean `%s`?%s', name, correctName, getStackAddendum());
15116 warnedProperties[name] = true;
15117 return true;
15118 }
15119 }
15120
15121 if (rARIA.test(name)) {
15122 var lowerCasedName = name.toLowerCase();
15123 var standardName = ariaProperties.hasOwnProperty(lowerCasedName) ? lowerCasedName : null;
15124
15125 // If this is an aria-* attribute, but is not listed in the known DOM
15126 // DOM properties, then it is an invalid aria-* attribute.
15127 if (standardName == null) {
15128 warnedProperties[name] = true;
15129 return false;
15130 }
15131 // aria-* attributes should be lowercase; suggest the lowercase version.
15132 if (name !== standardName) {
15133 warning(false, 'Unknown ARIA attribute `%s`. Did you mean `%s`?%s', name, standardName, getStackAddendum());
15134 warnedProperties[name] = true;
15135 return true;
15136 }
15137 }
15138
15139 return true;
15140}
15141
15142function warnInvalidARIAProps(type, props) {
15143 var invalidProps = [];

Callers 1

warnInvalidARIAPropsFunction · 0.70

Calls 2

warningFunction · 0.85
getStackAddendumFunction · 0.70

Tested by

no test coverage detected