1010 * http://api.jqueryui.com/category/ui-core/
1111 */
1212
13+ const DISPLAY_NONE = "none" ;
14+ const DISPLAY_CONTENTS = "contents" ;
15+
1316const 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 / ;
1417
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+
1526function hidesContents ( element ) {
1627 const zeroSize = element . offsetWidth <= 0 && element . offsetHeight <= 0 ;
1728
@@ -21,11 +32,10 @@ function hidesContents(element) {
2132 try {
2233 // Otherwise we need to check some styles
2334 const style = window . getComputedStyle ( element ) ;
35+ const displayValue = style . getPropertyValue ( "display" ) ;
2436 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 ;
2939 } catch ( exception ) {
3040 // eslint-disable-next-line no-console
3141 console . warn ( "Failed to inspect element style" ) ;
@@ -68,9 +78,10 @@ export default function findTabbableDescendants(element) {
6878 const descendants = [ ] . slice
6979 . call ( element . querySelectorAll ( "*" ) , 0 )
7080 . 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+ ) ,
7485 [ ]
7586 ) ;
7687 return descendants . filter ( tabbable ) ;
0 commit comments