Skip to content

color-contrast fails on aria-hidden="true" elements #3659

@NickAb

Description

@NickAb

Product

axe-core

Product Version

4.4.3

Latest Version

  • I have tested the issue with the latest version of the product

Issue Description

Expectation

Elements marked aria-hidden="true" should be skipped by color-contrast rule as purely decorative (https://www.w3.org/TR/WCAG22/#contrast-minimum).

Actual

color-contrast rule fails on elements with low contrast intended to be decorative and marked aria-hidden="true".

How to Reproduce

html snippet

<i class="material-icon-i material-icons-extended _ngcontent-agc-196" role="img" aria-hidden="true">brightness_1</i>

sample unit test

// test/rule-matches/color-contrast-matches.js

it('should not match aria-hidden=true', function () {
    fixture.innerHTML = '<i aria-hidden="true">hi</i>';
    var target = fixture.querySelector('i');
    axe.testUtils.flatTreeSetup(fixture);
    assert.isFalse(rule.matches(target, axe.utils.getNodeFromTree(target)));
});

Additional context

https://www.w3.org/TR/WCAG22/#contrast-minimum

The visual presentation of text and images of text has a contrast ratio of at least 4.5:1, except for the following:
...

  • Incidental: Text or images of text that are part of an inactive user interface component, that are pure decoration, that are not visible to anyone, or that are part of a picture that contains significant other visual content, have no contrast requirement.
    ...

Metadata

Metadata

Assignees

Labels

color contrastColor contrast issuesfixBug fixesprA pr has been created for the issuerulesIssue or false result from an axe-core rule

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions