diff --git a/js/src/scrollspy.js b/js/src/scrollspy.js index 9156223111..6f7dd04f27 100644 --- a/js/src/scrollspy.js +++ b/js/src/scrollspy.js @@ -113,18 +113,13 @@ class ScrollSpy { this._offsets = [] this._targets = [] - this._scrollHeight = this._getScrollHeight() const targets = SelectorEngine.find(this._selector) targets.map(element => { - let target const targetSelector = getSelectorFromElement(element) - - if (targetSelector) { - target = SelectorEngine.findOne(targetSelector) - } + const target = targetSelector ? SelectorEngine.findOne(targetSelector) : null if (target) { const targetBCR = target.getBoundingClientRect()