diff --git a/__tests__/src/rules/aria-activedescendant-has-tabindex-test.js b/__tests__/src/rules/aria-activedescendant-has-tabindex-test.js index 941403ccd..917898e80 100644 --- a/__tests__/src/rules/aria-activedescendant-has-tabindex-test.js +++ b/__tests__/src/rules/aria-activedescendant-has-tabindex-test.js @@ -18,7 +18,7 @@ import rule from '../../../src/rules/aria-activedescendant-has-tabindex'; const ruleTester = new RuleTester(); const expectedError = { - message: 'An element that manages focus with `aria-activedescendant` must be tabbable', + message: 'An element that manages focus with `aria-activedescendant` must have a tabindex', type: 'JSXOpeningElement', }; @@ -57,25 +57,28 @@ ruleTester.run('aria-activedescendant-has-tabindex', rule, { { code: ';', }, + { + code: ';', + }, { code: ';', }, - ].map(parserOptionsMapper), - invalid: [ { - code: '
;', - errors: [expectedError], + code: ';', }, { code: ';', - errors: [expectedError], }, { code: ';', - errors: [expectedError], }, { code: ';', + }, + ].map(parserOptionsMapper), + invalid: [ + { + code: ';', errors: [expectedError], }, ].map(parserOptionsMapper), diff --git a/src/rules/aria-activedescendant-has-tabindex.js b/src/rules/aria-activedescendant-has-tabindex.js index 23546f9b2..50e66f666 100644 --- a/src/rules/aria-activedescendant-has-tabindex.js +++ b/src/rules/aria-activedescendant-has-tabindex.js @@ -13,7 +13,7 @@ import isInteractiveElement from '../util/isInteractiveElement'; // Rule Definition // ---------------------------------------------------------------------------- -const errorMessage = 'An element that manages focus with `aria-activedescendant` must be tabbable'; +const errorMessage = 'An element that manages focus with `aria-activedescendant` must have a tabindex'; const schema = generateObjSchema(); @@ -43,21 +43,17 @@ module.exports = { } const tabIndex = getTabIndex(getProp(attributes, 'tabIndex')); - // If this is an interactive element, tabIndex must be either left - // unspecified allowing the inherent tabIndex to obtain or it must be - // zero (allowing for positive, even though that is not ideal). It cannot - // be given a negative value. + // If this is an interactive element and the tabindex attribute is not specified, + // or the tabIndex property was not mutated, then the tabIndex + // property will be undefined. if ( isInteractiveElement(type, attributes) - && ( - tabIndex === undefined - || tabIndex >= 0 - ) + && tabIndex === undefined ) { return; } - if (tabIndex >= 0) { + if (tabIndex >= -1) { return; }