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

Function validateProperty

code/composition/public/app.js:15874–15917  ·  view source on GitHub ↗
(tagName, name)

Source from the content-addressed store, hash-verified

15872}
15873
15874function validateProperty(tagName, name) {
15875 if (hasOwnProperty.call(warnedProperties, name) && warnedProperties[name]) {
15876 return true;
15877 }
15878
15879 if (rARIACamel.test(name)) {
15880 var ariaName = 'aria-' + name.slice(4).toLowerCase();
15881 var correctName = ariaProperties.hasOwnProperty(ariaName) ? ariaName : null;
15882
15883 // If this is an aria-* attribute, but is not listed in the known DOM
15884 // DOM properties, then it is an invalid aria-* attribute.
15885 if (correctName == null) {
15886 warning(false, 'Invalid ARIA attribute `%s`. ARIA attributes follow the pattern aria-* and must be lowercase.%s', name, getStackAddendum());
15887 warnedProperties[name] = true;
15888 return true;
15889 }
15890 // aria-* attributes should be lowercase; suggest the lowercase version.
15891 if (name !== correctName) {
15892 warning(false, 'Invalid ARIA attribute `%s`. Did you mean `%s`?%s', name, correctName, getStackAddendum());
15893 warnedProperties[name] = true;
15894 return true;
15895 }
15896 }
15897
15898 if (rARIA.test(name)) {
15899 var lowerCasedName = name.toLowerCase();
15900 var standardName = ariaProperties.hasOwnProperty(lowerCasedName) ? lowerCasedName : null;
15901
15902 // If this is an aria-* attribute, but is not listed in the known DOM
15903 // DOM properties, then it is an invalid aria-* attribute.
15904 if (standardName == null) {
15905 warnedProperties[name] = true;
15906 return false;
15907 }
15908 // aria-* attributes should be lowercase; suggest the lowercase version.
15909 if (name !== standardName) {
15910 warning(false, 'Unknown ARIA attribute `%s`. Did you mean `%s`?%s', name, standardName, getStackAddendum());
15911 warnedProperties[name] = true;
15912 return true;
15913 }
15914 }
15915
15916 return true;
15917}
15918
15919function warnInvalidARIAProps(type, props) {
15920 var invalidProps = [];

Callers 1

warnInvalidARIAPropsFunction · 0.70

Calls 2

warningFunction · 0.85
getStackAddendumFunction · 0.70

Tested by

no test coverage detected