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(color-contrast): add special case for new sr-only technique #2985

Merged
merged 4 commits into from
Jun 15, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
6 changes: 5 additions & 1 deletion lib/commons/dom/is-visible.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,15 @@ function isVisible(el, screenReader, recursed) {
}

// hidden from visual users
const elHeight = parseInt(style.getPropertyValue('height'));
if (
!screenReader &&
(isClipped(style) ||
style.getPropertyValue('opacity') === '0' ||
(getScroll(el) && parseInt(style.getPropertyValue('height')) === 0))
(getScroll(el) && elHeight === 0) ||
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason you left this at 0?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, turns out it wasn't relevant to the case I was trying to address so I left it alone. Would you rather it be bumped up too?

(style.getPropertyValue('position') === 'absolute' &&
elHeight <= 1 &&
clottman marked this conversation as resolved.
Show resolved Hide resolved
style.getPropertyValue('overflow') === 'hidden'))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

6 line if statement's a bit much. Can you isolate some of the logic on this?

) {
return false;
}
Expand Down
7 changes: 7 additions & 0 deletions test/commons/dom/is-visible.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,13 @@ describe('dom.isVisible', function() {
assert.isFalse(axe.commons.dom.isVisible(el.actualNode));
}
);
it('should return false if element is visually hidden using position absolute, overflow hidden, and a very small height', function() {
fixture.innerHTML =
'<div id="target" style="position:absolute; height: 1px; overflow: hidden;">StickySticky</div>';
var el = document.getElementById('target');

assert.isFalse(axe.commons.dom.isVisible(el));
});
});

describe('screen readers', function() {
Expand Down