File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change 44// the first parent with a scroll bar (including auto, which
55// on some devices hides the scroll bar until hovered).
66exports . getScrollParent = node => ( ) => {
7- const isElement = node instanceof HTMLElement ;
8- const computedStyle = isElement && window . getComputedStyle ( node ) ;
7+ if ( ! ( node instanceof HTMLElement ) ) {
8+ return document . body ;
9+ }
10+
11+ const computedStyle = window . getComputedStyle ( node ) ;
912 const overflowY = computedStyle && computedStyle . overflowY ;
1013 const overflowX = computedStyle && computedStyle . overflowX ;
1114 const isScrollable =
@@ -14,12 +17,10 @@ exports.getScrollParent = node => () => {
1417 ( overflowX &&
1518 ! ( overflowX . includes ( "visible" ) || overflowX . includes ( "hidden" ) ) ) ;
1619
17- if ( ! node ) {
18- return document . body ;
19- } else if ( isScrollable && node . scrollHeight >= node . clientHeight ) {
20+ if ( isScrollable && node . scrollHeight >= node . clientHeight ) {
2021 return node ;
2122 } else {
22- return exports . getScrollParent ( node . parentNode ) ;
23+ return exports . getScrollParent ( node . parentNode ) ( ) ;
2324 }
2425} ;
2526
You can’t perform that action at this time.
0 commit comments