From b36754e6650ed664f2b321c90c5a3a3d86db9689 Mon Sep 17 00:00:00 2001 From: Steven Lambert Date: Wed, 28 Aug 2019 10:38:27 -0600 Subject: [PATCH] fix(scrollable-region-focus): ignore scrollable regions without content (#1788) * fix(has-content-virtual): fix bug with ignoreAria flag * add test --- lib/commons/dom/has-content-virtual.js | 2 +- test/commons/dom/has-content-virtual.js | 2 +- test/rule-matches/scrollable-region-focusable-matches.js | 8 ++++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/commons/dom/has-content-virtual.js b/lib/commons/dom/has-content-virtual.js index eb5e9b9d69..4a91344da2 100644 --- a/lib/commons/dom/has-content-virtual.js +++ b/lib/commons/dom/has-content-virtual.js @@ -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( diff --git a/test/commons/dom/has-content-virtual.js b/test/commons/dom/has-content-virtual.js index acebe380b5..cb84e322e7 100644 --- a/test/commons/dom/has-content-virtual.js +++ b/test/commons/dom/has-content-virtual.js @@ -41,7 +41,7 @@ describe('dom.hasContentVirtual', function() { it('is false if the element has an aria label but `ignoreAria=true`', function() { fixture.innerHTML = '
'; tree = axe.utils.getFlattenedTree(fixture); - assert.isTrue( + assert.isFalse( hasContentVirtual( axe.utils.querySelectorAll(tree, '#target')[0], true, diff --git a/test/rule-matches/scrollable-region-focusable-matches.js b/test/rule-matches/scrollable-region-focusable-matches.js index 94a77be3fb..f2d373fc9f 100644 --- a/test/rule-matches/scrollable-region-focusable-matches.js +++ b/test/rule-matches/scrollable-region-focusable-matches.js @@ -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( + '
' + ); + var actual = rule.matches(target.actualNode, target); + assert.isFalse(actual); + }); + describe('shadowDOM - scrollable-region-focusable-matches', function() { before(function() { if (!shadowSupported) {