File tree Expand file tree Collapse file tree 3 files changed +18
-4
lines changed Expand file tree Collapse file tree 3 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ npm install scrollparent --save
1313``` js
1414var Scrollparent = require (" scrollparent" );
1515
16- Scrollparent (document .getElementById (" content" )) // document.body
16+ Scrollparent (document .getElementById (" content" )) // HTMLHtmlElement or HTMLBodyElement as appropriate
1717```
1818
1919``` js
@@ -22,6 +22,20 @@ var Scrollparent = require("scrollparent");
2222Scrollparent (document .getElementById (" inside-a-scrolling-div" )) // HTMLDivElement
2323```
2424
25+ ## Note about the root scrolling element
26+
27+ Internally, the root scrolling element is determined in this library
28+ as the result of
29+
30+ ``` js
31+ document .scrollingElement || document .htmlElement
32+ ```
33+
34+ This should give a usable result in most browsers today
35+ but if you want to ensure full support
36+ you should use a ` document.scrollingElement ` polyfill such as
37+ [ this one] ( https://github.com/mathiasbynens/document.scrollingElement ) .
38+
2539## Contributors
2640
2741* Ola Holmström (@olahol )
Original file line number Diff line number Diff line change 4040 }
4141 }
4242
43- return document . body ;
43+ return document . scrollingElement || document . documentElement ;
4444 } ;
4545
4646 return scrollParent ;
Original file line number Diff line number Diff line change 127127
128128equal ( Scrollparent ( document . getElementById ( "test1" ) ) . className , "scroll" ) ;
129129
130- equal ( Scrollparent ( document . getElementById ( "test2" ) ) , document . body ) ;
131- equal ( Scrollparent ( document . getElementById ( "test3" ) ) , document . body ) ;
130+ equal ( Scrollparent ( document . getElementById ( "test2" ) ) , document . scrollingElement || document . documentElement ) ;
131+ equal ( Scrollparent ( document . getElementById ( "test3" ) ) , document . scrollingElement || document . documentElement ) ;
132132
133133equal ( Scrollparent ( document . getElementById ( "test4" ) ) . className , "scroll-y" ) ;
134134equal ( Scrollparent ( document . getElementById ( "test5" ) ) . className , "scroll-x" ) ;
You can’t perform that action at this time.
0 commit comments