diff --git a/lib/commons/color/get-background-color.js b/lib/commons/color/get-background-color.js index 916f02d4a3..e3b937ca73 100644 --- a/lib/commons/color/get-background-color.js +++ b/lib/commons/color/get-background-color.js @@ -284,6 +284,14 @@ color.filteredRectStack = function(elm) { let rectA = rectStack[index - 1], rectB = rectStack[index]; + // If either rect are undefined, we cannot complete the test. We exit + // early to avoid unhelpful errors. + // See https://github.com/dequelabs/axe-core/issues/1306. + if (rectA === undefined || rectB === undefined) { + isSame = false; + return; + } + // if elements in clientRects are the same // or the boundingClientRect contains the differing element, pass it isSame =