@@ -12,7 +12,12 @@ import cache from '../../core/base/cache';
12
12
* @param {Element } node
13
13
*/
14
14
const getVisibleChildTextRects = memoize (
15
- function getVisibleChildTextRectsMemoized ( node ) {
15
+ function getVisibleChildTextRectsMemoized (
16
+ node ,
17
+ checkTextRectOutsideNodeBoundingRect = false ,
18
+ checkIsOutsideNodeBounds = true ,
19
+ includeOverflowHiddenRect = false
20
+ ) {
16
21
const vNode = getNodeFromTree ( node ) ;
17
22
const nodeRect = vNode . boundingClientRect ;
18
23
const clientRects = [ ] ;
@@ -24,18 +29,34 @@ const getVisibleChildTextRects = memoize(
24
29
}
25
30
26
31
const contentRects = getContentRects ( textNode ) ;
27
- if ( isOutsideNodeBounds ( contentRects , nodeRect ) && ! cache . get ( 'ruleId' ) ) {
28
- return ;
32
+ if ( checkIsOutsideNodeBounds ) {
33
+ if (
34
+ isOutsideNodeBounds (
35
+ contentRects ,
36
+ nodeRect ,
37
+ checkTextRectOutsideNodeBoundingRect
38
+ ) &&
39
+ ! cache . get ( 'ruleId' )
40
+ ) {
41
+ return ;
42
+ }
29
43
}
30
44
31
- clientRects . push ( ...filterHiddenRects ( contentRects , overflowHiddenNodes ) ) ;
45
+ if ( includeOverflowHiddenRect ) {
46
+ clientRects . push (
47
+ ...filterHiddenRects ( contentRects , overflowHiddenNodes )
48
+ ) ;
49
+ } else {
50
+ clientRects . push ( ...filterHiddenRects ( contentRects , [ ] ) ) ;
51
+ }
32
52
} ) ;
33
53
34
54
// a11y-engine-domforge change
35
55
if (
36
56
clientRects . length <= 0 &&
37
57
cache . get ( 'ruleId' ) &&
38
- cache . get ( 'ruleId' ) === 'resize-2x-zoom'
58
+ cache . get ( 'ruleId' ) === 'resize-2x-zoom' &&
59
+ checkIsOutsideNodeBounds
39
60
) {
40
61
return [ ] ;
41
62
}
@@ -72,10 +93,18 @@ function getContentRects(node) {
72
93
* when determining the rect stack we will also use the midpoint
73
94
* of the text rect to determine out of bounds
74
95
*/
75
- function isOutsideNodeBounds ( rects , nodeRect ) {
96
+ function isOutsideNodeBounds (
97
+ rects ,
98
+ nodeRect ,
99
+ checkTextRectOutsideNodeBoundingRect = false
100
+ ) {
76
101
return rects . some ( rect => {
77
102
const centerPoint = getRectCenter ( rect ) ;
78
- return ! isPointInRect ( centerPoint , nodeRect ) ;
103
+ if ( checkTextRectOutsideNodeBoundingRect ) {
104
+ ! isPointInRect ( centerPoint , nodeRect ) || rect . right > nodeRect . right ;
105
+ } else {
106
+ return ! isPointInRect ( centerPoint , nodeRect ) ;
107
+ }
79
108
} ) ;
80
109
}
81
110
0 commit comments