Skip to content

Commit 6cee221

Browse files
committed
null handling for color contrast
1 parent 993f0ba commit 6cee221

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lib/checks/color/color-contrast-evaluate.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ export default function colorContrastEvaluate(node, options, virtualNode) {
8282
}
8383

8484
const bgNodes = [];
85+
axe._cache.set('ruleId', 'axe-color-contrast');
8586
const bgColor = getBackgroundColor(node, bgNodes, shadowOutlineEmMax);
8687
const fgColor = getForegroundColor(node, false, bgColor, options);
8788

lib/commons/dom/get-rect-stack.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import visuallySort from './visually-sort';
22
import { getRectCenter } from '../math';
3+
import cache from '../../core/base/cache';
34

45
// Additional props isCoordsPassed, x, y for a11y-engine-domforge
56
export function getRectStack(
@@ -41,7 +42,12 @@ export function getRectStack(
4142
});
4243

4344
const gridContainer = grid.container;
44-
if (gridContainer) {
45+
//adding just if color contrast is being run then only then the extra added condition should run
46+
if (
47+
gridContainer &&
48+
(!(cache.get('ruleId') && cache.get('ruleId') === 'axe-color-contrast') ||
49+
gridContainer._grid)
50+
) {
4551
stack = getRectStack(
4652
gridContainer._grid,
4753
gridContainer.boundingClientRect,

0 commit comments

Comments
 (0)