From 940de070cc97665601743e2847a3ed1df9bcd6f9 Mon Sep 17 00:00:00 2001 From: Steven Lambert Date: Thu, 30 May 2019 09:16:10 -0600 Subject: [PATCH] fix(scrollable-region-focusable): exclude overflow:hidden as not scrollable (#1599) * fix(scrollable-region-focusable): exlcude overflow:hidden as not scrollable * remove comments --- lib/core/utils/get-scroll.js | 8 ++++++-- test/core/utils/get-scroll.js | 5 +---- test/core/utils/scroll-state.js | 2 +- .../scrollable-region-focusable.html | 20 +++++++++---------- .../scrollable-region-focusable.json | 2 +- .../scrollable-region-focusable-matches.js | 4 ++-- 6 files changed, 21 insertions(+), 20 deletions(-) diff --git a/lib/core/utils/get-scroll.js b/lib/core/utils/get-scroll.js index a0702da148..8782aa9cf3 100644 --- a/lib/core/utils/get-scroll.js +++ b/lib/core/utils/get-scroll.js @@ -19,8 +19,12 @@ axe.utils.getScroll = function getScroll(elm, buffer = 0) { } const style = window.getComputedStyle(elm); - const scrollableX = style.getPropertyValue('overflow-x') !== 'visible'; - const scrollableY = style.getPropertyValue('overflow-y') !== 'visible'; + const overflowXStyle = style.getPropertyValue('overflow-x'); + const overflowYStyle = style.getPropertyValue('overflow-y'); + const scrollableX = + overflowXStyle !== 'visible' && overflowXStyle !== 'hidden'; + const scrollableY = + overflowYStyle !== 'visible' && overflowYStyle !== 'hidden'; /** * check direction of `overflow` and `scrollable` diff --git a/test/core/utils/get-scroll.js b/test/core/utils/get-scroll.js index 64b887bc9b..72065b0434 100644 --- a/test/core/utils/get-scroll.js +++ b/test/core/utils/get-scroll.js @@ -42,10 +42,7 @@ describe('axe.utils.getScroll', function() { '' ); var actual = axe.utils.getScroll(target.actualNode); - assert.isDefined(actual); - assert.hasAllKeys(actual, ['elm', 'top', 'left']); - assert.equal(actual.top, 0); - assert.equal(actual.left, 0); + assert.isUndefined(actual); }); it('returns scroll offset when element overflow is auto', function() { diff --git a/test/core/utils/scroll-state.js b/test/core/utils/scroll-state.js index a8cf6ed1d4..8df4d6700c 100644 --- a/test/core/utils/scroll-state.js +++ b/test/core/utils/scroll-state.js @@ -53,7 +53,7 @@ describe('axe.utils.getScrollState', function() { fixture.innerHTML = '
' + '
Han Solo
' + - '
' + + '
' + '
Chewbacca
' + '
' + '
'; diff --git a/test/integration/rules/scrollable-region-focusable/scrollable-region-focusable.html b/test/integration/rules/scrollable-region-focusable/scrollable-region-focusable.html index 5f5369b148..3ee4ed78f7 100644 --- a/test/integration/rules/scrollable-region-focusable/scrollable-region-focusable.html +++ b/test/integration/rules/scrollable-region-focusable/scrollable-region-focusable.html @@ -1,9 +1,9 @@ -
+
-
+

Content

@@ -17,17 +17,11 @@
-
-
-

Content

-
-
- -
+
-
+
@@ -68,3 +62,9 @@

Content

+ +
+
+

Content

+
+
diff --git a/test/integration/rules/scrollable-region-focusable/scrollable-region-focusable.json b/test/integration/rules/scrollable-region-focusable/scrollable-region-focusable.json index bec306c304..44d2f4d059 100644 --- a/test/integration/rules/scrollable-region-focusable/scrollable-region-focusable.json +++ b/test/integration/rules/scrollable-region-focusable/scrollable-region-focusable.json @@ -1,6 +1,6 @@ { "description": "scrollable-region-focusable tests", "rule": "scrollable-region-focusable", - "violations": [["#fail1"], ["#fail2"], ["#fail3"]], + "violations": [["#fail1"], ["#fail2"]], "passes": [["#pass1"], ["#pass2"], ["#pass3"]] } diff --git a/test/rule-matches/scrollable-region-focusable-matches.js b/test/rule-matches/scrollable-region-focusable-matches.js index 91667bcd5b..94a77be3fb 100644 --- a/test/rule-matches/scrollable-region-focusable-matches.js +++ b/test/rule-matches/scrollable-region-focusable-matches.js @@ -42,7 +42,7 @@ describe('scrollable-region-focusable-matches', function() { assert.isFalse(actual); }); - it('returns true when element is scrollable (overflow=hidden)', function() { + it('returns false when element is not scrollable (overflow=hidden)', function() { var target = queryFixture( '
' + '
' + @@ -51,7 +51,7 @@ describe('scrollable-region-focusable-matches', function() { '
' ); var actual = rule.matches(target.actualNode, target); - assert.isTrue(actual); + assert.isFalse(actual); }); it('returns true when element is scrollable (overflow=auto)', function() {