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

Function validateProperty

code/higher-order-components/public/app.js:15730–15773  ·  view source on GitHub ↗
(tagName, name)

Source from the content-addressed store, hash-verified

15728}
15729
15730function validateProperty(tagName, name) {
15731 if (hasOwnProperty.call(warnedProperties, name) && warnedProperties[name]) {
15732 return true;
15733 }
15734
15735 if (rARIACamel.test(name)) {
15736 var ariaName = 'aria-' + name.slice(4).toLowerCase();
15737 var correctName = ariaProperties.hasOwnProperty(ariaName) ? ariaName : null;
15738
15739 // If this is an aria-* attribute, but is not listed in the known DOM
15740 // DOM properties, then it is an invalid aria-* attribute.
15741 if (correctName == null) {
15742 warning(false, 'Invalid ARIA attribute `%s`. ARIA attributes follow the pattern aria-* and must be lowercase.%s', name, getStackAddendum());
15743 warnedProperties[name] = true;
15744 return true;
15745 }
15746 // aria-* attributes should be lowercase; suggest the lowercase version.
15747 if (name !== correctName) {
15748 warning(false, 'Invalid ARIA attribute `%s`. Did you mean `%s`?%s', name, correctName, getStackAddendum());
15749 warnedProperties[name] = true;
15750 return true;
15751 }
15752 }
15753
15754 if (rARIA.test(name)) {
15755 var lowerCasedName = name.toLowerCase();
15756 var standardName = ariaProperties.hasOwnProperty(lowerCasedName) ? lowerCasedName : null;
15757
15758 // If this is an aria-* attribute, but is not listed in the known DOM
15759 // DOM properties, then it is an invalid aria-* attribute.
15760 if (standardName == null) {
15761 warnedProperties[name] = true;
15762 return false;
15763 }
15764 // aria-* attributes should be lowercase; suggest the lowercase version.
15765 if (name !== standardName) {
15766 warning(false, 'Unknown ARIA attribute `%s`. Did you mean `%s`?%s', name, standardName, getStackAddendum());
15767 warnedProperties[name] = true;
15768 return true;
15769 }
15770 }
15771
15772 return true;
15773}
15774
15775function warnInvalidARIAProps(type, props) {
15776 var invalidProps = [];

Callers 1

warnInvalidARIAPropsFunction · 0.70

Calls 2

warningFunction · 0.85
getStackAddendumFunction · 0.70

Tested by

no test coverage detected