Skip to content

Commit 80bf267

Browse files
committed
Updated axe-core files for 200% zoom
1 parent 3945146 commit 80bf267

File tree

5 files changed

+86
-49
lines changed

5 files changed

+86
-49
lines changed

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import createGrid from './create-grid';
99
* @param {Node} node
1010
* @return {Node[]}
1111
*/
12-
function getElementStack(node) {
12+
function getElementStack(node, isCoordsPassed = false, x, y) {
1313
createGrid();
1414

1515
const vNode = getNodeFromTree(node);
@@ -19,7 +19,14 @@ function getElementStack(node) {
1919
return [];
2020
}
2121

22-
return getRectStack(grid, vNode.boundingClientRect);
22+
return getRectStack(
23+
grid,
24+
vNode.boundingClientRect,
25+
false,
26+
isCoordsPassed,
27+
x,
28+
y
29+
);
2330
}
2431

2532
export default getElementStack;

lib/commons/dom/get-overflow-hidden-ancestors.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ const getOverflowHiddenAncestors = memoize(
1717

1818
const overflow = vNode.getComputedStylePropertyValue('overflow');
1919

20-
if (overflow === 'hidden') {
20+
if (
21+
overflow.includes('hidden') ||
22+
overflow.includes('clip') ||
23+
overflow.includes('scroll')
24+
) {
2125
ancestors.push(vNode);
2226
}
2327

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

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
11
import visuallySort from './visually-sort';
22
import { getRectCenter } from '../math';
33

4-
export function getRectStack(grid, rect, recursed = false) {
4+
export function getRectStack(
5+
grid,
6+
rect,
7+
recursed = false,
8+
isCoordsPassed,
9+
x,
10+
y
11+
) {
512
const center = getRectCenter(rect);
613
const gridCell = grid.getCellFromPoint(center) || [];
714

8-
const floorX = Math.floor(center.x);
9-
const floorY = Math.floor(center.y);
15+
let floorX = Math.floor(center.x);
16+
let floorY = Math.floor(center.y);
17+
18+
if (isCoordsPassed) {
19+
floorX = Math.floor(x);
20+
floorY = Math.floor(y);
21+
}
22+
1023
let stack = gridCell.filter(gridCellNode => {
1124
return gridCellNode.clientRects.some(clientRect => {
1225
const rectX = clientRect.left;

lib/commons/dom/get-visible-child-text-rects.js

Lines changed: 55 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { getNodeFromTree, memoize } from '../../core/utils';
1+
import { getNodeFromTree } from '../../core/utils';
22
import { sanitize } from '../text';
3-
import { getRectCenter, isPointInRect, getIntersectionRect } from '../math';
3+
import { getIntersectionRect } from '../math';
44
import getOverflowHiddenAncestors from './get-overflow-hidden-ancestors';
55

66
/**
@@ -10,45 +10,56 @@ import getOverflowHiddenAncestors from './get-overflow-hidden-ancestors';
1010
* @instance
1111
* @param {Element} node
1212
*/
13-
const getVisibleChildTextRects = memoize(
14-
function getVisibleChildTextRectsMemoized(node) {
15-
const vNode = getNodeFromTree(node);
16-
const nodeRect = vNode.boundingClientRect;
17-
const clientRects = [];
18-
const overflowHiddenNodes = getOverflowHiddenAncestors(vNode);
13+
const getVisibleChildTextRects = function getVisibleChildTextRectsMemoized(
14+
node
15+
) {
16+
const vNode = getNodeFromTree(node);
17+
const nodeRect = vNode.boundingClientRect;
18+
const clientRects = [];
19+
const overflowHiddenNodes = getOverflowHiddenAncestors(vNode);
1920

20-
node.childNodes.forEach(textNode => {
21-
if (textNode.nodeType !== 3 || sanitize(textNode.nodeValue) === '') {
22-
return;
23-
}
21+
// console.log("Here");
22+
// console.log("Child Nodes are ", node.childNodes);
2423

25-
const contentRects = getContentRects(textNode);
26-
if (isOutsideNodeBounds(contentRects, nodeRect)) {
27-
return;
28-
}
24+
node.childNodes.forEach(textNode => {
25+
if (textNode.nodeType !== 3 || sanitize(textNode.nodeValue) === '') {
26+
return;
27+
}
28+
29+
const contentRects = getContentRects(textNode);
30+
// if (isOutsideNodeBounds(contentRects, nodeRect)) {
31+
// return;
32+
// }
33+
34+
// console.log("Client Rects ate ", structuredClone(contentRects));
2935

30-
clientRects.push(...filterHiddenRects(contentRects, overflowHiddenNodes));
31-
});
36+
clientRects.push(...filterHiddenRects(contentRects, overflowHiddenNodes));
37+
});
3238

33-
/**
34-
* if all text rects are larger than the bounds of the node,
35-
* or goes outside of the bounds of the node, we need to use
36-
* the nodes bounding rect so we stay within the bounds of the
37-
* element.
38-
*
39-
* @see https://github.com/dequelabs/axe-core/issues/2178
40-
* @see https://github.com/dequelabs/axe-core/issues/2483
41-
* @see https://github.com/dequelabs/axe-core/issues/2681
42-
*
43-
* also need to resize the nodeRect to fit within the bounds of any overflow: hidden ancestors.
44-
*
45-
* @see https://github.com/dequelabs/axe-core/issues/4253
46-
*/
47-
return clientRects.length
48-
? clientRects
49-
: filterHiddenRects([nodeRect], overflowHiddenNodes);
39+
if (clientRects.length <= 0) {
40+
return [];
5041
}
51-
);
42+
/**
43+
* if all text rects are larger than the bounds of the node,
44+
* or goes outside of the bounds of the node, we need to use
45+
* the nodes bounding rect so we stay within the bounds of the
46+
* element.
47+
*
48+
* @see https://github.com/dequelabs/axe-core/issues/2178
49+
* @see https://github.com/dequelabs/axe-core/issues/2483
50+
* @see https://github.com/dequelabs/axe-core/issues/2681
51+
*
52+
* also need to resize the nodeRect to fit within the bounds of any overflow: hidden ancestors.
53+
*
54+
* @see https://github.com/dequelabs/axe-core/issues/4253
55+
*/
56+
57+
// console.log("Node is ", node);
58+
// console.log("Client Rects is ", clientRects);
59+
return clientRects.length
60+
? clientRects
61+
: filterHiddenRects([nodeRect], overflowHiddenNodes);
62+
};
5263
export default getVisibleChildTextRects;
5364

5465
function getContentRects(node) {
@@ -63,12 +74,12 @@ function getContentRects(node) {
6374
* when determining the rect stack we will also use the midpoint
6475
* of the text rect to determine out of bounds
6576
*/
66-
function isOutsideNodeBounds(rects, nodeRect) {
67-
return rects.some(rect => {
68-
const centerPoint = getRectCenter(rect);
69-
return !isPointInRect(centerPoint, nodeRect);
70-
});
71-
}
77+
// function isOutsideNodeBounds(rects, nodeRect) {
78+
// return rects.some(rect => {
79+
// const centerPoint = getRectCenter(rect);
80+
// return !isPointInRect(centerPoint, nodeRect);
81+
// });
82+
// }
7283

7384
/**
7485
* Filter out 0 width and height rects (newline characters) and
@@ -86,7 +97,9 @@ function filterHiddenRects(contentRects, overflowHiddenNodes) {
8697

8798
// update the rect size to fit inside the bounds of all overflow
8899
// hidden ancestors
100+
// console.log("Overflow Hidden nodes are ", overflowHiddenNodes);
89101
const visibleRect = overflowHiddenNodes.reduce((rect, overflowNode) => {
102+
// console.log("Overflow node is ", overflowNode);
90103
return rect && getIntersectionRect(rect, overflowNode.boundingClientRect);
91104
}, contentRect);
92105

lib/core/constants.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const definitions = [
2727

2828
const constants = {
2929
helpUrlBase: 'https://dequeuniversity.com/rules/',
30-
gridSize: 200,
30+
gridSize: 500,
3131
results: [],
3232
resultGroups: [],
3333
resultGroupMap: {},

0 commit comments

Comments
 (0)