1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-06 21:56:42 +02:00

scrollspy.js: chain functions (#35139)

This commit is contained in:
XhmikosR
2021-10-08 12:28:05 +03:00
committed by GitHub
parent 64e13162fa
commit eb0f705621

View File

@@ -110,25 +110,26 @@ class ScrollSpy extends BaseComponent {
this._scrollHeight = this._getScrollHeight() this._scrollHeight = this._getScrollHeight()
const targets = SelectorEngine.find(SELECTOR_LINK_ITEMS, this._config.target) const targets = SelectorEngine.find(SELECTOR_LINK_ITEMS, this._config.target)
.map(element => {
const targetSelector = getSelectorFromElement(element)
const target = targetSelector ? SelectorEngine.findOne(targetSelector) : null
for (const item of targets.map(element => { if (target) {
const targetSelector = getSelectorFromElement(element) const targetBCR = target.getBoundingClientRect()
const target = targetSelector ? SelectorEngine.findOne(targetSelector) : null if (targetBCR.width || targetBCR.height) {
return [
if (target) { Manipulator[offsetMethod](target).top + offsetBase,
const targetBCR = target.getBoundingClientRect() targetSelector
if (targetBCR.width || targetBCR.height) { ]
return [ }
Manipulator[offsetMethod](target).top + offsetBase,
targetSelector
]
} }
}
return null return null
}) })
.filter(item => item) .filter(item => item)
.sort((a, b) => a[0] - b[0])) { .sort((a, b) => a[0] - b[0])
for (const item of targets) {
this._offsets.push(item[0]) this._offsets.push(item[0])
this._targets.push(item[1]) this._targets.push(item[1])
} }