]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
scrollspy.js: chain functions (#35139)
authorXhmikosR <xhmikosr@gmail.com>
Fri, 8 Oct 2021 09:28:05 +0000 (12:28 +0300)
committerGitHub <noreply@github.com>
Fri, 8 Oct 2021 09:28:05 +0000 (12:28 +0300)
js/src/scrollspy.js

index df9a14e220b4a95219e8d5c098d676cd039632d6..e0e2e9bf913ea4cf29f333991d00ec6a98d6dd92 100644 (file)
@@ -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])
     }