-
Notifications
You must be signed in to change notification settings - Fork 784
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): correctly compute color-contrast of truncated children #3203
Conversation
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.
Looks good, just a few minor points
* Assumes that |parent| is an ancestor of |node|. | ||
* @param {Element} node | ||
* @param {Element} parent | ||
* @return {boolean} True if node is visually contained within parent | ||
*/ | ||
function contains(node, parent) { | ||
const rectBound = node.getBoundingClientRect(); | ||
const margin = 0.01; |
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.
Why did you remove the margin?
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.
Why do we need the margin?
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.
Rounding errors
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.
If that's the case, I would rather use Math.ceil
and Math.floor
to handle rounding issues rather than use a magic number. It makes it way more clear what the intent is.
); | ||
var expected = new axe.commons.color.Color(0, 255, 0, 1); | ||
document.documentElement.style.background = orig; | ||
assert.isNull(actual); |
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.
Wow... That's all I have to say about this.
Co-authored-by: Wilco Fiers <WilcoFiers@users.noreply.github.com>
…core into visually-contains
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.
Would like to see margin be put back.
…ildren (#3203) * fixes * finalize * sort * test * fix tests * Update lib/commons/color/get-background-stack.js Co-authored-by: Wilco Fiers <WilcoFiers@users.noreply.github.com> * fixes * split out pr * order * rounding Co-authored-by: Wilco Fiers <WilcoFiers@users.noreply.github.com>
This pr is dependent on #3207
The
visuallyContains
code was hard to understand what it was doing, so I refactored it to simplify it. Now it doesn't need to do thescrollTop
andscrollLeft
checking and only does a single compare to determine if the element is fully inside the other.Closes issue: #2669