From 45eb74682c8460fbd6f1de273e710b597ff01392 Mon Sep 17 00:00:00 2001 From: Steven Lambert <2433219+straker@users.noreply.github.com> Date: Fri, 14 Aug 2020 10:47:21 -0600 Subject: [PATCH] fix(color-contrast): dont error for floating element (#2444) * Update reduce-to-elements-below-floating.js Found this as a bug when testing on a site. * add test --- .../dom/reduce-to-elements-below-floating.js | 2 +- test/checks/color/color-contrast.js | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/commons/dom/reduce-to-elements-below-floating.js b/lib/commons/dom/reduce-to-elements-below-floating.js index 31a4dc751e..fa17a815aa 100644 --- a/lib/commons/dom/reduce-to-elements-below-floating.js +++ b/lib/commons/dom/reduce-to-elements-below-floating.js @@ -9,7 +9,7 @@ */ function reduceToElementsBelowFloating(elements, targetNode) { const floatingPositions = ['fixed', 'sticky']; - const finalElements = []; + let finalElements = []; let targetFound = false; // Filter out elements that are temporarily floating above the target diff --git a/test/checks/color/color-contrast.js b/test/checks/color/color-contrast.js index 068cd56869..d24ddfa47a 100644 --- a/test/checks/color/color-contrast.js +++ b/test/checks/color/color-contrast.js @@ -188,6 +188,20 @@ describe('color-contrast', function() { assert.deepEqual(checkContext._relatedNodes, [expectedRelatedNodes]); }); + it('should ignore position:fixed elements directly above the target', function() { + var params = checkSetup( + '