Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/bootstrap.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXhmikosR <xhmikosr@gmail.com>2021-10-08 12:28:05 +0300
committerGitHub <noreply@github.com>2021-10-08 12:28:05 +0300
commiteb0f705621a044d25d6de0e5d1b4dde306b5004d (patch)
tree3551dc733fa906e9d6129350735d8eeee93e372a
parent64e13162faa692aa2d12071ad9a14a3ac1b08a6f (diff)
scrollspy.js: chain functions (#35139)
-rw-r--r--js/src/scrollspy.js35
1 files changed, 18 insertions, 17 deletions
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])
}