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

Function validateProperty

code/one-direction-data-flow/public/app.js:15609–15652  ·  view source on GitHub ↗
(tagName, name)

Source from the content-addressed store, hash-verified

15607}
15608
15609function validateProperty(tagName, name) {
15610 if (hasOwnProperty.call(warnedProperties, name) && warnedProperties[name]) {
15611 return true;
15612 }
15613
15614 if (rARIACamel.test(name)) {
15615 var ariaName = 'aria-' + name.slice(4).toLowerCase();
15616 var correctName = ariaProperties.hasOwnProperty(ariaName) ? ariaName : null;
15617
15618 // If this is an aria-* attribute, but is not listed in the known DOM
15619 // DOM properties, then it is an invalid aria-* attribute.
15620 if (correctName == null) {
15621 warning(false, 'Invalid ARIA attribute `%s`. ARIA attributes follow the pattern aria-* and must be lowercase.%s', name, getStackAddendum());
15622 warnedProperties[name] = true;
15623 return true;
15624 }
15625 // aria-* attributes should be lowercase; suggest the lowercase version.
15626 if (name !== correctName) {
15627 warning(false, 'Invalid ARIA attribute `%s`. Did you mean `%s`?%s', name, correctName, getStackAddendum());
15628 warnedProperties[name] = true;
15629 return true;
15630 }
15631 }
15632
15633 if (rARIA.test(name)) {
15634 var lowerCasedName = name.toLowerCase();
15635 var standardName = ariaProperties.hasOwnProperty(lowerCasedName) ? lowerCasedName : null;
15636
15637 // If this is an aria-* attribute, but is not listed in the known DOM
15638 // DOM properties, then it is an invalid aria-* attribute.
15639 if (standardName == null) {
15640 warnedProperties[name] = true;
15641 return false;
15642 }
15643 // aria-* attributes should be lowercase; suggest the lowercase version.
15644 if (name !== standardName) {
15645 warning(false, 'Unknown ARIA attribute `%s`. Did you mean `%s`?%s', name, standardName, getStackAddendum());
15646 warnedProperties[name] = true;
15647 return true;
15648 }
15649 }
15650
15651 return true;
15652}
15653
15654function warnInvalidARIAProps(type, props) {
15655 var invalidProps = [];

Callers 1

warnInvalidARIAPropsFunction · 0.70

Calls 2

warningFunction · 0.85
getStackAddendumFunction · 0.70

Tested by

no test coverage detected