diff options
| author | Johann-S <[email protected]> | 2018-04-30 16:37:45 +0200 |
|---|---|---|
| committer | Johann-S <[email protected]> | 2018-06-01 10:30:11 +0200 |
| commit | b1eb3fccfa722afc4f7ca0d00eb848353ce8aed8 (patch) | |
| tree | 638af933a31acaabdedacf9a99a66e94662e6ae5 /js/src/scrollspy.js | |
| parent | 62cc0fda50781606da5989b5a6eba6770bc34a51 (diff) | |
| download | bootstrap-b1eb3fccfa722afc4f7ca0d00eb848353ce8aed8.tar.xz bootstrap-b1eb3fccfa722afc4f7ca0d00eb848353ce8aed8.zip | |
refactor(plugins): improve how we query elements
Diffstat (limited to 'js/src/scrollspy.js')
| -rw-r--r-- | js/src/scrollspy.js | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/js/src/scrollspy.js b/js/src/scrollspy.js index 90905b05d..02cab5372 100644 --- a/js/src/scrollspy.js +++ b/js/src/scrollspy.js @@ -225,7 +225,8 @@ const ScrollSpy = (($) => { return } - for (let i = this._offsets.length; i--;) { + const offsetLength = this._offsets.length + for (let i = offsetLength; i--;) { const isActiveTarget = this._activeTarget !== this._targets[i] && scrollTop >= this._offsets[i] && (typeof this._offsets[i + 1] === 'undefined' || @@ -302,9 +303,10 @@ const ScrollSpy = (($) => { */ $(window).on(Event.LOAD_DATA_API, () => { - const scrollSpys = $.makeArray($(Selector.DATA_SPY)) + const scrollSpys = [].slice.call(document.querySelectorAll(Selector.DATA_SPY)) - for (let i = scrollSpys.length; i--;) { + const scrollSpysLength = scrollSpys.length + for (let i = scrollSpysLength; i--;) { const $spy = $(scrollSpys[i]) ScrollSpy._jQueryInterface.call($spy, $spy.data()) } |
