-
Notifications
You must be signed in to change notification settings - Fork 765
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): ignore aria-disabled labels #2130
Conversation
If an element is a descendent of an aria-labelledby reference, and any of the elements referencing it has disabled, the label must be ignored by the color-contrast rule.
lib/rules/color-contrast-matches.js
Outdated
return false; | ||
const ariaLabelledbyControls = []; | ||
let ancestorNode = virtualNode; | ||
while (ancestorNode) { |
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.
This is going to very slow on large pages as it will check the entire parent tree for every node (include subnodes of nodes already checked). The result of this gathering should be cached on each of the nodes checked so the next subnode only has to look up 1 level to find the answer.
See https://github.com/dequelabs/axe-core/blob/develop/lib/core/utils/is-hidden.js for a similar approach.
Also, we just merged a PR that updated the entire |
Co-authored-by: Steven Lambert <2433219+straker@users.noreply.github.com>
candidate = querySelectorAll( | ||
relevantVirtualNode, | ||
// implicit label of disabled control | ||
const query = |
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 we have an explicit control, do we need to check for an implicit one as well if the explicit control is not disabled?
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.
I don't think so. If an elm has an explicit label, the implicit one will not be applied.
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.
The way this if
statement above is written, if the element has an explicit label and it's not disabled, it will continue to look at the implicit label. Based on your answer we would get into a state where if the explicit label is not disable but the implicit one is, we would ignore the element even though the implicit label should not apply.
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.
Thought about this, I think fixing this is well outside of the scope of this PR. I'll open an issue for it instead.
Co-authored-by: Steven Lambert <2433219+straker@users.noreply.github.com>
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.
The if statement will allow a disabled implicit label to override the non-disabled explicit label.
If an element is a descendent of an aria-labelledby reference, and any of the elements referencing it has disabled, the label must be ignored by the color-contrast rule.
Closes issue: #2090
Reviewer checks
Required fields, to be filled out by PR reviewer(s)