-
Notifications
You must be signed in to change notification settings - Fork 779
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): inconsistency of bgOverlap message based on scroll #3310
Conversation
46c2d24
to
3f0fd31
Compare
@@ -1046,7 +1080,7 @@ describe('color.getBackgroundColor', function() { | |||
|
|||
it('returns the html background when body does not cover the element', function() { | |||
fixture.innerHTML = | |||
'<div id="target" style="position: absolute; top: 1000px;"><label>elm<input></label></div>'; | |||
'<div id="target" style="position: absolute; top: 1000px;">elm<input></div>'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rule would never target the parent of en element with text.
} | ||
// Ignore inline descendants, for example: | ||
// <p>text <img></p>; We don't care about the <img> element, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if <img>
is positioned somehow, acting like a background?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
position: absolute / sticky force an element into display:block. I'll put in a test for it though.
bgOverlap was not computed correctly. What it was doing is use elementsFromPoint on the top-right pixel of a field. It got the tests to pass, but doing that doesn't actually tell us the difference between an element that overlaps, and a non-text element that simply sits inline with the text of an element. Because axe-core no longer scrolls the page when running color-contrast, our use of elementsFromPoint caused inconsistencies.
The fix here is to check if an element that appears visually on top of the element with text is actually an inline descendant of it. That gets rid of elementsFromPoint, solving the inconsistency problem, and it means we can actually properly tell what elements might overlap, and which ones are in the same flow as the text.
Closes issue: #3309