source: frontend/node_modules/eslint-plugin-jsx-a11y/lib/rules/aria-activedescendant-has-tabindex.js

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

Fix frontend appearance

  • Property mode set to 100644
File size: 2.5 KB
Line 
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports["default"] = void 0;
7var _ariaQuery = require("aria-query");
8var _jsxAstUtils = require("jsx-ast-utils");
9var _schemas = require("../util/schemas");
10var _getElementType = _interopRequireDefault(require("../util/getElementType"));
11var _getTabIndex = _interopRequireDefault(require("../util/getTabIndex"));
12var _isInteractiveElement = _interopRequireDefault(require("../util/isInteractiveElement"));
13function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
14/**
15 * @fileoverview Enforce elements with aria-activedescendant are tabbable.
16 * @author Jesse Beach <@jessebeach>
17 */
18
19// ----------------------------------------------------------------------------
20// Rule Definition
21// ----------------------------------------------------------------------------
22
23var errorMessage = 'An element that manages focus with `aria-activedescendant` must have a tabindex';
24var schema = (0, _schemas.generateObjSchema)();
25var _default = exports["default"] = {
26 meta: {
27 docs: {
28 url: 'https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/aria-activedescendant-has-tabindex.md',
29 description: 'Enforce elements with aria-activedescendant are tabbable.'
30 },
31 schema: [schema]
32 },
33 create: function create(context) {
34 var elementType = (0, _getElementType["default"])(context);
35 return {
36 JSXOpeningElement: function JSXOpeningElement(node) {
37 var attributes = node.attributes;
38 if ((0, _jsxAstUtils.getProp)(attributes, 'aria-activedescendant') === undefined) {
39 return;
40 }
41 var type = elementType(node);
42 // Do not test higher level JSX components, as we do not know what
43 // low-level DOM element this maps to.
44 if (!_ariaQuery.dom.has(type)) {
45 return;
46 }
47 var tabIndex = (0, _getTabIndex["default"])((0, _jsxAstUtils.getProp)(attributes, 'tabIndex'));
48
49 // If this is an interactive element and the tabindex attribute is not specified,
50 // or the tabIndex property was not mutated, then the tabIndex
51 // property will be undefined.
52 if ((0, _isInteractiveElement["default"])(type, attributes) && tabIndex === undefined) {
53 return;
54 }
55 if (tabIndex >= -1) {
56 return;
57 }
58 context.report({
59 node,
60 message: errorMessage
61 });
62 }
63 };
64 }
65};
66module.exports = exports.default;
Note: See TracBrowser for help on using the repository browser.