From: XhmikosR Date: Fri, 8 Oct 2021 09:28:05 +0000 (+0300) Subject: scrollspy.js: chain functions (#35139) X-Git-Tag: v5.2.0-beta1~469 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=eb0f705621a044d25d6de0e5d1b4dde306b5004d;p=thirdparty%2Fbootstrap.git scrollspy.js: chain functions (#35139) --- diff --git a/js/src/scrollspy.js b/js/src/scrollspy.js index df9a14e220..e0e2e9bf91 100644 --- a/js/src/scrollspy.js +++ b/js/src/scrollspy.js @@ -110,25 +110,26 @@ class ScrollSpy extends BaseComponent { this._scrollHeight = this._getScrollHeight() const targets = SelectorEngine.find(SELECTOR_LINK_ITEMS, this._config.target) - - for (const item of targets.map(element => { - const targetSelector = getSelectorFromElement(element) - const target = targetSelector ? SelectorEngine.findOne(targetSelector) : null - - if (target) { - const targetBCR = target.getBoundingClientRect() - if (targetBCR.width || targetBCR.height) { - return [ - Manipulator[offsetMethod](target).top + offsetBase, - targetSelector - ] + .map(element => { + const targetSelector = getSelectorFromElement(element) + const target = targetSelector ? SelectorEngine.findOne(targetSelector) : null + + if (target) { + const targetBCR = target.getBoundingClientRect() + if (targetBCR.width || targetBCR.height) { + return [ + Manipulator[offsetMethod](target).top + offsetBase, + targetSelector + ] + } } - } - return null - }) - .filter(item => item) - .sort((a, b) => a[0] - b[0])) { + return null + }) + .filter(item => item) + .sort((a, b) => a[0] - b[0]) + + for (const item of targets) { this._offsets.push(item[0]) this._targets.push(item[1]) }