10
10
* http://api.jqueryui.com/category/ui-core/
11
11
*/
12
12
13
+ const DISPLAY_NONE = "none" ;
14
+ const DISPLAY_CONTENTS = "contents" ;
15
+
13
16
const tabbableNode = / i n p u t | s e l e c t | t e x t a r e a | b u t t o n | o b j e c t | i f r a m e / ;
14
17
18
+ function isNotOverflowing ( element , style ) {
19
+ return (
20
+ style . getPropertyValue ( "overflow" ) !== "visible" ||
21
+ // if 'overflow: visible' set, check if there is actually any overflow
22
+ ( element . scrollWidth <= 0 && element . scrollHeight <= 0 )
23
+ ) ;
24
+ }
25
+
15
26
function hidesContents ( element ) {
16
27
const zeroSize = element . offsetWidth <= 0 && element . offsetHeight <= 0 ;
17
28
@@ -21,11 +32,10 @@ function hidesContents(element) {
21
32
try {
22
33
// Otherwise we need to check some styles
23
34
const style = window . getComputedStyle ( element ) ;
35
+ const displayValue = style . getPropertyValue ( "display" ) ;
24
36
return zeroSize
25
- ? style . getPropertyValue ( "overflow" ) !== "visible" ||
26
- // if 'overflow: visible' set, check if there is actually any overflow
27
- ( element . scrollWidth <= 0 && element . scrollHeight <= 0 )
28
- : style . getPropertyValue ( "display" ) == "none" ;
37
+ ? displayValue !== DISPLAY_CONTENTS && isNotOverflowing ( element , style )
38
+ : displayValue === DISPLAY_NONE ;
29
39
} catch ( exception ) {
30
40
// eslint-disable-next-line no-console
31
41
console . warn ( "Failed to inspect element style" ) ;
@@ -68,9 +78,10 @@ export default function findTabbableDescendants(element) {
68
78
const descendants = [ ] . slice
69
79
. call ( element . querySelectorAll ( "*" ) , 0 )
70
80
. reduce (
71
- ( finished , el ) => finished . concat (
72
- ! el . shadowRoot ? [ el ] : findTabbableDescendants ( el . shadowRoot )
73
- ) ,
81
+ ( finished , el ) =>
82
+ finished . concat (
83
+ ! el . shadowRoot ? [ el ] : findTabbableDescendants ( el . shadowRoot )
84
+ ) ,
74
85
[ ]
75
86
) ;
76
87
return descendants . filter ( tabbable ) ;
0 commit comments