Skip to content

Commit

Permalink
refactor(check): undo recent split of checks
Browse files Browse the repository at this point in the history
Recombine checks "no-focusable-content-for-aria-text" and "no-focusable-content-for-nested-interactive" back into "no-focusable-content".
  • Loading branch information
dan-tripp committed Oct 9, 2021
1 parent d788c6c commit 493fc39
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 106 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function usesUnreliableHidingStrategy(vNode) {
return !isNaN(tabIndex) && tabIndex < 0 && vNode.attr('aria-hidden') === 'true';
}

function noFocusableContentForNestedInteractiveEvaluate(node, options, virtualNode) {
function noFocusableContentEvaluate(node, options, virtualNode) {
if (!virtualNode.children) {
return undefined;
}
Expand All @@ -47,4 +47,4 @@ function noFocusableContentForNestedInteractiveEvaluate(node, options, virtualNo
}
}

export default noFocusableContentForNestedInteractiveEvaluate;
export default noFocusableContentEvaluate;
35 changes: 0 additions & 35 deletions lib/checks/keyboard/no-focusable-content-for-aria-text-evaluate.js

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "no-focusable-content-for-aria-text",
"evaluate": "no-focusable-content-for-aria-text-evaluate",
"id": "no-focusable-content",
"evaluate": "no-focusable-content-evaluate",
"metadata": {
"impact": "serious",
"messages": {
Expand Down
6 changes: 2 additions & 4 deletions lib/core/base/metadata-function-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ import focusableNoNameEvaluate from '../../checks/keyboard/focusable-no-name-eva
import focusableNotTabbableEvaluate from '../../checks/keyboard/focusable-not-tabbable-evaluate';
import landmarkIsTopLevelEvaluate from '../../checks/keyboard/landmark-is-top-level-evaluate';
import noFocusableContentForFrameEvaluate from '../../checks/keyboard/frame-focusable-content-evaluate';
import noFocusableContentForAriaTextEvaluate from '../../checks/keyboard/no-focusable-content-for-aria-text-evaluate';
import noFocusableContentForNestedInteractiveEvaluate from '../../checks/keyboard/no-focusable-content-for-nested-interactive-evaluate';
import noFocusableContentEvaluate from '../../checks/keyboard/no-focusable-content-evaluate';
import tabindexEvaluate from '../../checks/keyboard/tabindex-evaluate';

// label
Expand Down Expand Up @@ -276,8 +275,7 @@ const metadataFunctionMap = {
'focusable-not-tabbable-evaluate': focusableNotTabbableEvaluate,
'landmark-is-top-level-evaluate': landmarkIsTopLevelEvaluate,
'no-focusable-content-for-frame-evaluate': noFocusableContentForFrameEvaluate,
'no-focusable-content-for-aria-text-evaluate': noFocusableContentForAriaTextEvaluate,
'no-focusable-content-for-nested-interactive-evaluate': noFocusableContentForNestedInteractiveEvaluate,
'no-focusable-content-evaluate': noFocusableContentEvaluate,
'tabindex-evaluate': tabindexEvaluate,

// label
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/aria-text.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
"help": "\"role=text\" should have no focusable descendants"
},
"all": [],
"any": ["no-focusable-content-for-aria-text"],
"any": ["no-focusable-content"],
"none": []
}
2 changes: 1 addition & 1 deletion lib/rules/nested-interactive.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
"help": "Ensure interactive controls are not nested"
},
"all": [],
"any": ["no-focusable-content-for-nested-interactive"],
"any": ["no-focusable-content"],
"none": []
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
describe('no-focusable-content-for-aria-text tests', function() {
describe('no-focusable-content tests', function() {
var fixture = document.querySelector('#fixture');
var queryFixture = axe.testUtils.queryFixture;
var noFocusableContentForAriaText = axe.testUtils.getCheckEvaluate(
'no-focusable-content-for-aria-text'
var noFocusableContent = axe.testUtils.getCheckEvaluate(
'no-focusable-content'
);

afterEach(function() {
Expand All @@ -11,31 +11,31 @@ describe('no-focusable-content-for-aria-text tests', function() {

it('should return true if element has no focusable content', function() {
var vNode = queryFixture('<button id="target"><span>Hello</span></button>');
assert.isTrue(noFocusableContentForAriaText(null, null, vNode));
assert.isTrue(noFocusableContent(null, null, vNode));
});

it('should return true if element is empty', function() {
var vNode = queryFixture('<button id="target"></button>');
assert.isTrue(noFocusableContentForAriaText(null, null, vNode));
assert.isTrue(noFocusableContent(null, null, vNode));
});

it('should return true if element only has text content', function() {
var vNode = queryFixture('<button id="target">Hello</button>');
assert.isTrue(noFocusableContentForAriaText(null, null, vNode));
assert.isTrue(noFocusableContent(null, null, vNode));
});

it('should return false if element has focusable content', function() {
var vNode = queryFixture(
'<button id="target"><span tabindex="0">Hello</span></button>'
);
assert.isFalse(noFocusableContentForAriaText(null, null, vNode));
assert.isFalse(noFocusableContent(null, null, vNode));
});

it('should return false if element has natively focusable content', function() {
var vNode = queryFixture(
'<button id="target"><a href="foo.html">Hello</a></button>'
);
assert.isFalse(noFocusableContentForAriaText(null, null, vNode));
assert.isFalse(noFocusableContent(null, null, vNode));
});

});

0 comments on commit 493fc39

Please sign in to comment.