fix(color-contrast): account for elements that do not fill entire bounding size#3186
fix(color-contrast): account for elements that do not fill entire bounding size#3186
Conversation
lib/commons/dom/get-rect-stack.js
Outdated
| const endRow = ((y + rect.height) / gridSize) | 0; | ||
| const endCol = ((x + rect.width) / gridSize) | 0; | ||
|
|
||
| grid._numCols = Math.max(grid._numCols ?? 0, endCol); |
There was a problem hiding this comment.
This feels a little off. If _numCols needs to be different, it should be fixed where that value is set. If it doesn't need to be changed, this should probably just be a local variable.
There was a problem hiding this comment.
It needs to be set for every grid, so can't be local. Grid items are added dynamically, so there's no way to know how many rows or columns the grid will have before hand, we can only know as each item is added and changes the grid size.
| // can't be an element whose midpoint is at column 5. If this happens this | ||
| // means there's an error in our grid logic that needs to be fixed | ||
| if (row > grid.cells.length || col > grid._numCols) { | ||
| throw new Error('Element midpoint exceeds the grid bounds'); |
There was a problem hiding this comment.
I don't follow why you would want this to throw. Crashing axe-core doesn't seem like the right solution here.
There was a problem hiding this comment.
Because I want to know when our custom grid logic fails, and it shows there's an issue that needs to be fixed. Without throwing, color contrast would hide issues that should be fixed.
…nding size (#3186) * fix(color-contrast): account for elements that do not fill entire bounding size * not private
Closes issue: #3166