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

Function validateProperty

code/dependency-injection/public/app.js:15829–15872  ·  view source on GitHub ↗
(tagName, name)

Source from the content-addressed store, hash-verified

15827}
15828
15829function validateProperty(tagName, name) {
15830 if (hasOwnProperty.call(warnedProperties, name) && warnedProperties[name]) {
15831 return true;
15832 }
15833
15834 if (rARIACamel.test(name)) {
15835 var ariaName = 'aria-' + name.slice(4).toLowerCase();
15836 var correctName = ariaProperties.hasOwnProperty(ariaName) ? ariaName : null;
15837
15838 // If this is an aria-* attribute, but is not listed in the known DOM
15839 // DOM properties, then it is an invalid aria-* attribute.
15840 if (correctName == null) {
15841 warning(false, 'Invalid ARIA attribute `%s`. ARIA attributes follow the pattern aria-* and must be lowercase.%s', name, getStackAddendum());
15842 warnedProperties[name] = true;
15843 return true;
15844 }
15845 // aria-* attributes should be lowercase; suggest the lowercase version.
15846 if (name !== correctName) {
15847 warning(false, 'Invalid ARIA attribute `%s`. Did you mean `%s`?%s', name, correctName, getStackAddendum());
15848 warnedProperties[name] = true;
15849 return true;
15850 }
15851 }
15852
15853 if (rARIA.test(name)) {
15854 var lowerCasedName = name.toLowerCase();
15855 var standardName = ariaProperties.hasOwnProperty(lowerCasedName) ? lowerCasedName : null;
15856
15857 // If this is an aria-* attribute, but is not listed in the known DOM
15858 // DOM properties, then it is an invalid aria-* attribute.
15859 if (standardName == null) {
15860 warnedProperties[name] = true;
15861 return false;
15862 }
15863 // aria-* attributes should be lowercase; suggest the lowercase version.
15864 if (name !== standardName) {
15865 warning(false, 'Unknown ARIA attribute `%s`. Did you mean `%s`?%s', name, standardName, getStackAddendum());
15866 warnedProperties[name] = true;
15867 return true;
15868 }
15869 }
15870
15871 return true;
15872}
15873
15874function warnInvalidARIAProps(type, props) {
15875 var invalidProps = [];

Callers 1

warnInvalidARIAPropsFunction · 0.70

Calls 2

warningFunction · 0.85
getStackAddendumFunction · 0.70

Tested by

no test coverage detected