aboutsummaryrefslogtreecommitdiff
path: root/js/src/scrollspy.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/scrollspy.js')
-rw-r--r--js/src/scrollspy.js13
1 files changed, 7 insertions, 6 deletions
diff --git a/js/src/scrollspy.js b/js/src/scrollspy.js
index 6ac00fedd..0bcbaa88e 100644
--- a/js/src/scrollspy.js
+++ b/js/src/scrollspy.js
@@ -9,7 +9,8 @@ import {
defineJQueryPlugin,
getElement,
getSelectorFromElement,
- typeCheckConfig
+ typeCheckConfig,
+ getWindow
} from './util/index'
import EventHandler from './dom/event-handler'
import Manipulator from './dom/manipulator'
@@ -67,7 +68,7 @@ const METHOD_POSITION = 'position'
class ScrollSpy extends BaseComponent {
constructor(element, config) {
super(element)
- this._scrollElement = this._element.tagName === 'BODY' ? window : this._element
+ this._scrollElement = this._element.tagName === 'BODY' ? this._window : this._element
this._config = this._getConfig(config)
this._offsets = []
this._targets = []
@@ -164,14 +165,14 @@ class ScrollSpy extends BaseComponent {
_getScrollHeight() {
return this._scrollElement.scrollHeight || Math.max(
- document.body.scrollHeight,
- document.documentElement.scrollHeight
+ this._document.body.scrollHeight,
+ this._document.documentElement.scrollHeight
)
}
_getOffsetHeight() {
return this._scrollElement === window ?
- window.innerHeight :
+ this._window.innerHeight :
this._scrollElement.getBoundingClientRect().height
}
@@ -278,7 +279,7 @@ class ScrollSpy extends BaseComponent {
* ------------------------------------------------------------------------
*/
-EventHandler.on(window, EVENT_LOAD_DATA_API, () => {
+EventHandler.on(getWindow(), EVENT_LOAD_DATA_API, () => {
SelectorEngine.find(SELECTOR_DATA_SPY)
.forEach(spy => new ScrollSpy(spy))
})