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

Function validateProperty

code/communication/public/app.js:15771–15814  ·  view source on GitHub ↗
(tagName, name)

Source from the content-addressed store, hash-verified

15769}
15770
15771function validateProperty(tagName, name) {
15772 if (hasOwnProperty.call(warnedProperties, name) && warnedProperties[name]) {
15773 return true;
15774 }
15775
15776 if (rARIACamel.test(name)) {
15777 var ariaName = 'aria-' + name.slice(4).toLowerCase();
15778 var correctName = ariaProperties.hasOwnProperty(ariaName) ? ariaName : null;
15779
15780 // If this is an aria-* attribute, but is not listed in the known DOM
15781 // DOM properties, then it is an invalid aria-* attribute.
15782 if (correctName == null) {
15783 warning(false, 'Invalid ARIA attribute `%s`. ARIA attributes follow the pattern aria-* and must be lowercase.%s', name, getStackAddendum());
15784 warnedProperties[name] = true;
15785 return true;
15786 }
15787 // aria-* attributes should be lowercase; suggest the lowercase version.
15788 if (name !== correctName) {
15789 warning(false, 'Invalid ARIA attribute `%s`. Did you mean `%s`?%s', name, correctName, getStackAddendum());
15790 warnedProperties[name] = true;
15791 return true;
15792 }
15793 }
15794
15795 if (rARIA.test(name)) {
15796 var lowerCasedName = name.toLowerCase();
15797 var standardName = ariaProperties.hasOwnProperty(lowerCasedName) ? lowerCasedName : null;
15798
15799 // If this is an aria-* attribute, but is not listed in the known DOM
15800 // DOM properties, then it is an invalid aria-* attribute.
15801 if (standardName == null) {
15802 warnedProperties[name] = true;
15803 return false;
15804 }
15805 // aria-* attributes should be lowercase; suggest the lowercase version.
15806 if (name !== standardName) {
15807 warning(false, 'Unknown ARIA attribute `%s`. Did you mean `%s`?%s', name, standardName, getStackAddendum());
15808 warnedProperties[name] = true;
15809 return true;
15810 }
15811 }
15812
15813 return true;
15814}
15815
15816function warnInvalidARIAProps(type, props) {
15817 var invalidProps = [];

Callers 1

warnInvalidARIAPropsFunction · 0.70

Calls 2

warningFunction · 0.85
getStackAddendumFunction · 0.70

Tested by

no test coverage detected