Skip to content

Commit

Permalink
fix(scrollable-region-focus): ignore scrollable regions without conte…
Browse files Browse the repository at this point in the history
…nt (#1788)

* fix(has-content-virtual): fix bug with ignoreAria flag

* add test
  • Loading branch information
straker authored Aug 28, 2019
1 parent 281653d commit b36754e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/commons/dom/has-content-virtual.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ dom.hasContentVirtual = function(elm, noRecursion, ignoreAria) {
// It is a graphical element
dom.isVisualContent(elm.actualNode) ||
// It has an ARIA label
(!!ignoreAria || !!aria.labelVirtual(elm)) ||
(!ignoreAria && !!aria.labelVirtual(elm)) ||
// or one of it's descendants does
(!noRecursion &&
elm.children.some(
Expand Down
2 changes: 1 addition & 1 deletion test/commons/dom/has-content-virtual.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('dom.hasContentVirtual', function() {
it('is false if the element has an aria label but `ignoreAria=true`', function() {
fixture.innerHTML = '<div id="target" aria-label="my-label"> </div>';
tree = axe.utils.getFlattenedTree(fixture);
assert.isTrue(
assert.isFalse(
hasContentVirtual(
axe.utils.querySelectorAll(tree, '#target')[0],
true,
Expand Down
8 changes: 8 additions & 0 deletions test/rule-matches/scrollable-region-focusable-matches.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ describe('scrollable-region-focusable-matches', function() {
assert.isTrue(actual);
});

it('returns false when element overflow is scroll but has no content', function() {
var target = queryFixture(
'<div id="target" style="width: 12em; height: 2em; border: dotted; overflow: scroll;"><div style="height: 15rem"></div></div>'
);
var actual = rule.matches(target.actualNode, target);
assert.isFalse(actual);
});

describe('shadowDOM - scrollable-region-focusable-matches', function() {
before(function() {
if (!shadowSupported) {
Expand Down

0 comments on commit b36754e

Please sign in to comment.