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

Function validateProperty

code/styling/public/app.js:15736–15779  ·  view source on GitHub ↗
(tagName, name)

Source from the content-addressed store, hash-verified

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

Callers 1

warnInvalidARIAPropsFunction · 0.70

Calls 2

warningFunction · 0.85
getStackAddendumFunction · 0.70

Tested by

no test coverage detected