diff --git a/lib/rules/color-contrast-matches.js b/lib/rules/color-contrast-matches.js index 9a75b04b2f..d95b1c3890 100644 --- a/lib/rules/color-contrast-matches.js +++ b/lib/rules/color-contrast-matches.js @@ -1,6 +1,11 @@ /* global document */ import { getAccessibleRefs } from '../commons/aria'; -import { findUpVirtual, visuallyOverlaps, getRootNode } from '../commons/dom'; +import { + findUpVirtual, + visuallyOverlaps, + getRootNode, + isInert +} from '../commons/dom'; import { visibleVirtual, removeUnicode, @@ -35,7 +40,7 @@ function colorContrastMatches(node, virtualNode) { return false; } - if (isDisabled(virtualNode)) { + if (isDisabled(virtualNode) || isInert(virtualNode)) { return false; } diff --git a/test/integration/rules/color-contrast/color-contrast.html b/test/integration/rules/color-contrast/color-contrast.html index 1231e9cf86..dd3a114312 100644 --- a/test/integration/rules/color-contrast/color-contrast.html +++ b/test/integration/rules/color-contrast/color-contrast.html @@ -440,3 +440,11 @@ This div will be on top of the stack + +
hello
+ +
+
+
hello
+
+
diff --git a/test/rule-matches/color-contrast-matches.js b/test/rule-matches/color-contrast-matches.js index c9afeba4d8..382457119c 100644 --- a/test/rule-matches/color-contrast-matches.js +++ b/test/rule-matches/color-contrast-matches.js @@ -404,6 +404,20 @@ describe('color-contrast-matches', function () { assert.isFalse(rule.matches(target, axe.utils.getNodeFromTree(target))); }); + it('should not match inert', function () { + fixture.innerHTML = '
hi
'; + var target = fixture.querySelector('div'); + axe.testUtils.flatTreeSetup(fixture); + assert.isFalse(rule.matches(target, axe.utils.getNodeFromTree(target))); + }); + + it('should not match a descendant of inert', function () { + fixture.innerHTML = '
hi
'; + var target = fixture.querySelector('span'); + 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 =