Skip to content

Commit eb0f705

Browse files
authored
scrollspy.js: chain functions (twbs#35139)
1 parent 64e1316 commit eb0f705

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

js/src/scrollspy.js

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -110,25 +110,26 @@ class ScrollSpy extends BaseComponent {
110110
this._scrollHeight = this._getScrollHeight()
111111

112112
const targets = SelectorEngine.find(SELECTOR_LINK_ITEMS, this._config.target)
113-
114-
for (const item of targets.map(element => {
115-
const targetSelector = getSelectorFromElement(element)
116-
const target = targetSelector ? SelectorEngine.findOne(targetSelector) : null
117-
118-
if (target) {
119-
const targetBCR = target.getBoundingClientRect()
120-
if (targetBCR.width || targetBCR.height) {
121-
return [
122-
Manipulator[offsetMethod](target).top + offsetBase,
123-
targetSelector
124-
]
113+
.map(element => {
114+
const targetSelector = getSelectorFromElement(element)
115+
const target = targetSelector ? SelectorEngine.findOne(targetSelector) : null
116+
117+
if (target) {
118+
const targetBCR = target.getBoundingClientRect()
119+
if (targetBCR.width || targetBCR.height) {
120+
return [
121+
Manipulator[offsetMethod](target).top + offsetBase,
122+
targetSelector
123+
]
124+
}
125125
}
126-
}
127126

128-
return null
129-
})
130-
.filter(item => item)
131-
.sort((a, b) => a[0] - b[0])) {
127+
return null
128+
})
129+
.filter(item => item)
130+
.sort((a, b) => a[0] - b[0])
131+
132+
for (const item of targets) {
132133
this._offsets.push(item[0])
133134
this._targets.push(item[1])
134135
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy