Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 4 additions & 0 deletions lib/rules/color-contrast-matches.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ function colorContrastMatches(node, virtualNode) {
return false;
}

if (virtualNode.getComputedStylePropertyValue('font-size') === '0px') {
return false;
}

const range = document.createRange();
const childNodes = virtualNode.children;
for (let index = 0; index < childNodes.length; index++) {
Expand Down
7 changes: 7 additions & 0 deletions test/rule-matches/color-contrast-matches.js
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,13 @@ describe('color-contrast-matches', function () {
assert.isFalse(rule.matches(target, axe.utils.getNodeFromTree(target)));
});

it('should not match text with font-size: 0', () => {
fixture.innerHTML = '<div style="font-size: 0">hi</div>';
const target = fixture.querySelector('div');
axe.testUtils.flatTreeSetup(fixture);
assert.isFalse(rule.matches(target, axe.utils.getNodeFromTree(target)));
});

if (shadowSupport) {
it('should match a descendant of an element across a shadow boundary', function () {
fixture.innerHTML =
Expand Down
Loading