aboutsummaryrefslogtreecommitdiff
path: root/js/src
diff options
context:
space:
mode:
authorJason Golieb <[email protected]>2019-02-05 03:31:18 -0500
committerXhmikosR <[email protected]>2019-02-05 10:31:18 +0200
commite44d0475e07113dfb21b555658de6eac53083f98 (patch)
treec35b6620da0cb0b3c9948d6a0a56800e9ca8e22a /js/src
parent1139f62ca26be2057ff15550061adf6ac201b2a8 (diff)
downloadbootstrap-e44d0475e07113dfb21b555658de6eac53083f98.tar.xz
bootstrap-e44d0475e07113dfb21b555658de6eac53083f98.zip
Move dropdown offset function logic into private function. (#28138)
Diffstat (limited to 'js/src')
-rw-r--r--js/src/dropdown.js19
1 files changed, 13 insertions, 6 deletions
diff --git a/js/src/dropdown.js b/js/src/dropdown.js
index 9aaf5a339..31deaa725 100644
--- a/js/src/dropdown.js
+++ b/js/src/dropdown.js
@@ -319,24 +319,30 @@ class Dropdown {
return $(this._element).closest('.navbar').length > 0
}
- _getPopperConfig() {
- const offsetConf = {}
+ _getOffset() {
+ const offset = {}
+
if (typeof this._config.offset === 'function') {
- offsetConf.fn = (data) => {
+ offset.fn = (data) => {
data.offsets = {
...data.offsets,
- ...this._config.offset(data.offsets) || {}
+ ...this._config.offset(data.offsets, this._element) || {}
}
+
return data
}
} else {
- offsetConf.offset = this._config.offset
+ offset.offset = this._config.offset
}
+ return offset
+ }
+
+ _getPopperConfig() {
const popperConfig = {
placement: this._getPlacement(),
modifiers: {
- offset: offsetConf,
+ offset: this._getOffset(),
flip: {
enabled: this._config.flip
},
@@ -352,6 +358,7 @@ class Dropdown {
enabled: false
}
}
+
return popperConfig
}