Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(checks/no-focusable-disable): don't count non-disableable elements as disabled #3393

Merged
merged 49 commits into from
Feb 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
2467b3a
refactor(checks/navigation): improve `internal-link-present-evaluate`
dan-tripp Aug 20, 2021
bde2684
Merge branch 'dequelabs:develop' into develop
dan-tripp Sep 2, 2021
9f996bc
test commit 1
dan-tripp Sep 3, 2021
c011d2c
test commit 2
dan-tripp Sep 3, 2021
a386166
test commit 3
dan-tripp Sep 3, 2021
428e015
Merge branch 'dan-test-branch-1' into develop
dan-tripp Sep 3, 2021
31b19a3
Revert "Merge branch 'dan-test-branch-1' into develop"
dan-tripp Sep 3, 2021
ac32146
Revert "test commit 1"
dan-tripp Sep 3, 2021
6e389a1
Merge branch 'dequelabs:develop' into develop
dan-tripp Sep 10, 2021
739f035
Merge branch 'dequelabs:develop' into develop
dan-tripp Sep 15, 2021
30f0e01
fix(rule): allow "tabindex=-1" for rules "aria-text" and "nested-inte…
dan-tripp Sep 24, 2021
9caefd7
Merge branch 'dequelabs:develop' into develop
dan-tripp Oct 1, 2021
41fd8e2
Merge branch 'dequelabs:develop' into develop
dan-tripp Oct 3, 2021
7aeac06
Merge branch 'dequelabs:develop' into develop
dan-tripp Oct 8, 2021
c37be71
Merge branch 'dequelabs:develop' into develop
dan-tripp Oct 9, 2021
2896478
Merge branch 'dequelabs:develop' into develop
dan-tripp Oct 14, 2021
02cfb18
Merge branch 'dequelabs:develop' into develop
dan-tripp Oct 22, 2021
f2ae004
Merge branch 'dequelabs:develop' into develop
dan-tripp Oct 23, 2021
b687d45
Merge branch 'dequelabs:develop' into develop
dan-tripp Oct 27, 2021
0729846
Merge branch 'dequelabs:develop' into develop
dan-tripp Oct 28, 2021
b257208
Merge branch 'dequelabs:develop' into develop
dan-tripp Oct 31, 2021
6c5a5ed
Merge branch 'develop' of https://github.com/dequelabs/axe-core into …
dan-tripp Nov 27, 2021
0d92cf2
Merge pull request #4 from dan-tripp/dequelabs-develop-2
dan-tripp Nov 27, 2021
5baa656
Merge branch 'dequelabs:develop' into develop
dan-tripp Nov 27, 2021
40025ad
work in progress
dan-tripp Nov 28, 2021
f12379e
Merge pull request #5 from dan-tripp/dequelabs-develop-2
dan-tripp Nov 28, 2021
92dc637
work in progress
dan-tripp Nov 28, 2021
2666eeb
Merge pull request #6 from dan-tripp/dequelabs-develop-2
dan-tripp Nov 28, 2021
7e692b4
Merge branch 'dequelabs:develop' into develop
dan-tripp Nov 30, 2021
6d8a0f6
test commit 1
dan-tripp Sep 3, 2021
9373c58
Revert "test commit 1"
dan-tripp Sep 3, 2021
0a4fd4f
fix(rule): allow "tabindex=-1" for rules "aria-text" and "nested-inte…
dan-tripp Sep 24, 2021
d50b56a
work in progress
dan-tripp Nov 28, 2021
74d5656
work in progress
dan-tripp Nov 28, 2021
54329dd
fix whitespace
dan-tripp Nov 30, 2021
499768f
add new case to test test/checks/keyboard/no-focusable-content.js
dan-tripp Nov 30, 2021
8c32f03
change "disabled" test case in test/checks/keyboard/no-focusable-cont…
dan-tripp Nov 30, 2021
ed9da3e
Merge branch 'develop' into dequelabs-develop-2
dan-tripp Dec 5, 2021
99000d4
Merge branch 'dequelabs-develop-2' into develop
dan-tripp Dec 5, 2021
7ad504f
Merge branch 'develop' of https://github.com/dan-tripp/axe-core into …
dan-tripp Dec 5, 2021
e69a0f5
Merge branch 'dequelabs:develop' into develop
dan-tripp Dec 5, 2021
d6a5573
fix merge problem
dan-tripp Dec 5, 2021
9a61752
Merge remote-tracking branch 'remotes/origin/develop' into develop
dan-tripp Dec 5, 2021
02c91ed
Merge branch 'dequelabs:develop' into develop
dan-tripp Jan 22, 2022
18a7ac6
Merge branch 'dequelabs:develop' into develop
dan-tripp Feb 12, 2022
7c40451
Merge branch 'dequelabs:develop' into develop
dan-tripp Feb 21, 2022
593aaac
fix(commons/dom): focusDisabled() behavior
dan-tripp Feb 12, 2022
903fbd5
Update lib/commons/dom/focus-disabled.js
dan-tripp Feb 21, 2022
404a092
fix typo
dan-tripp Feb 21, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion lib/commons/dom/focus-disabled.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
import AbstractVirtualNode from '../../core/base/virtual-node/abstract-virtual-node';
import { getNodeFromTree } from '../../core/utils';
import isHiddenWithCSS from './is-hidden-with-css';
// Source: https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/disabled
const allowedDisabledNodeNames = [
'button',
'command',
'fieldset',
'keygen',
'optgroup',
'option',
'select',
'textarea',
'input'
];

function isDisabledAttrAllowed(nodeName) {
return allowedDisabledNodeNames.includes(nodeName);
}

/**
* Determines if focusing has been disabled on an element.
Expand All @@ -10,7 +26,7 @@ import isHiddenWithCSS from './is-hidden-with-css';
function focusDisabled(el) {
const vNode = el instanceof AbstractVirtualNode ? el : getNodeFromTree(el);

if (vNode.hasAttr('disabled')) {
if (isDisabledAttrAllowed(vNode.props.nodeName) && vNode.hasAttr('disabled')) {
return true;
}

Expand Down
7 changes: 7 additions & 0 deletions test/checks/keyboard/no-focusable-content.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ describe('no-focusable-content tests', function() {
assert.isTrue(noFocusableContent(null, null, vNode));
});

it('should return false if "disabled" is specified on an element which doesn\'t allow it', function() {
var params = checkSetup(
'<button id="target"><a href="foo.html" disabled>Hello</a></button>'
);
assert.isFalse(noFocusableContent.apply(checkContext, params));
});

it('should return true on span with negative tabindex (focusable, does not have a widget role)', function() {
var vNode = queryFixture('<span id="target" role="text"> some text '
+'<span tabIndex="-1">JavaScript is able to focus this</span> '
Expand Down