source: frontend/node_modules/eslint-plugin-jsx-a11y/lib/util/isSemanticRoleElement.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 13 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 1.7 KB
Line 
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports["default"] = void 0;
7var _axobjectQuery = require("axobject-query");
8var _jsxAstUtils = require("jsx-ast-utils");
9var isSemanticRoleElement = function isSemanticRoleElement(elementType, attributes) {
10 var roleAttr = (0, _jsxAstUtils.getProp)(attributes, 'role');
11 var res = false;
12 var roleAttrValue = (0, _jsxAstUtils.getLiteralPropValue)(roleAttr);
13 _axobjectQuery.elementAXObjects.forEach(function (axObjects, concept) {
14 if (res) {
15 return;
16 }
17 if (concept.name === elementType && (concept.attributes || []).every(function (cAttr) {
18 return attributes.some(function (attr) {
19 if (!attr.type || attr.type !== 'JSXAttribute') {
20 return false;
21 }
22 var namesMatch = cAttr.name === (0, _jsxAstUtils.propName)(attr);
23 var valuesMatch;
24 if (cAttr.value !== undefined) {
25 valuesMatch = cAttr.value === (0, _jsxAstUtils.getLiteralPropValue)(attr);
26 }
27 if (!namesMatch) {
28 return false;
29 }
30 return namesMatch && valuesMatch !== undefined ? valuesMatch : true;
31 });
32 })) {
33 axObjects.forEach(function (name) {
34 if (res) {
35 return;
36 }
37 var roles = _axobjectQuery.AXObjectRoles.get(name);
38 if (roles) {
39 roles.forEach(function (role) {
40 if (res === true) {
41 return;
42 }
43 if (role.name === roleAttrValue) {
44 res = true;
45 }
46 });
47 }
48 });
49 }
50 });
51 return res;
52};
53var _default = exports["default"] = isSemanticRoleElement;
54module.exports = exports.default;
Note: See TracBrowser for help on using the repository browser.