77 root . Scrollparent = factory ( ) ;
88 }
99} ( this , function ( ) {
10- var regex = / ( a u t o | s c r o l l ) / ;
10+ function isScrolling ( node ) {
11+ var overflow = getComputedStyle ( node , null ) . getPropertyValue ( "overflow" ) ;
1112
12- var parents = function ( node , ps ) {
13- if ( node . parentNode === null ) { return ps ; }
14-
15- return parents ( node . parentNode , ps . concat ( [ node ] ) ) ;
16- } ;
17-
18- var style = function ( css , prop ) {
19- return css . getPropertyValue ( prop ) ;
20- } ;
21-
22- var overflow = function ( node ) {
23- var css = getComputedStyle ( node , null ) ;
24- return style ( css , "overflow" ) + style ( css , "overflow-y" ) + style ( css , "overflow-x" ) ;
25- } ;
26-
27- var scroll = function ( node ) {
28- return regex . test ( overflow ( node ) ) ;
29- } ;
13+ return overflow . indexOf ( "scroll" ) > - 1 || overflow . indexOf ( "auto" ) > - 1 ;
14+ }
3015
31- var scrollParent = function ( node ) {
16+ function scrollParent ( node ) {
3217 if ( ! ( node instanceof HTMLElement || node instanceof SVGElement ) ) {
33- return ;
18+ return undefined ;
3419 }
3520
36- var ps = parents ( node . parentNode , [ ] ) ;
37-
38- for ( var i = 0 ; i < ps . length ; i += 1 ) {
39- if ( scroll ( ps [ i ] ) ) {
40- return ps [ i ] ;
21+ var current = node . parentNode ;
22+ while ( current . parentNode ) {
23+ if ( isScrolling ( current ) ) {
24+ return current ;
4125 }
26+
27+ current = current . parentNode ;
4228 }
4329
4430 return document . scrollingElement || document . documentElement ;
45- } ;
31+ }
4632
4733 return scrollParent ;
48- } ) ) ;
34+ } ) ) ;
0 commit comments