aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/twbs/bootstrap/js/src/dropdown.js
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/twbs/bootstrap/js/src/dropdown.js')
-rw-r--r--vendor/twbs/bootstrap/js/src/dropdown.js79
1 files changed, 41 insertions, 38 deletions
diff --git a/vendor/twbs/bootstrap/js/src/dropdown.js b/vendor/twbs/bootstrap/js/src/dropdown.js
index d336a46d9..f907c0849 100644
--- a/vendor/twbs/bootstrap/js/src/dropdown.js
+++ b/vendor/twbs/bootstrap/js/src/dropdown.js
@@ -1,6 +1,6 @@
/**
* --------------------------------------------------------------------------
- * Bootstrap (v4.3.1): dropdown.js
+ * Bootstrap (v4.4.1): dropdown.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* --------------------------------------------------------------------------
*/
@@ -16,7 +16,7 @@ import Util from './util'
*/
const NAME = 'dropdown'
-const VERSION = '4.3.1'
+const VERSION = '4.4.1'
const DATA_KEY = 'bs.dropdown'
const EVENT_KEY = `.${DATA_KEY}`
const DATA_API_KEY = '.data-api'
@@ -71,19 +71,21 @@ const AttachmentMap = {
}
const Default = {
- offset : 0,
- flip : true,
- boundary : 'scrollParent',
- reference : 'toggle',
- display : 'dynamic'
+ offset : 0,
+ flip : true,
+ boundary : 'scrollParent',
+ reference : 'toggle',
+ display : 'dynamic',
+ popperConfig : null
}
const DefaultType = {
- offset : '(number|string|function)',
- flip : 'boolean',
- boundary : '(string|element)',
- reference : '(string|element)',
- display : 'string'
+ offset : '(number|string|function)',
+ flip : 'boolean',
+ boundary : '(string|element)',
+ reference : '(string|element)',
+ display : 'string',
+ popperConfig : '(null|object)'
}
/**
@@ -124,7 +126,6 @@ class Dropdown {
return
}
- const parent = Dropdown._getParentFromElement(this._element)
const isActive = $(this._menu).hasClass(ClassName.SHOW)
Dropdown._clearMenus()
@@ -133,10 +134,19 @@ class Dropdown {
return
}
+ this.show(true)
+ }
+
+ show(usePopper = false) {
+ if (this._element.disabled || $(this._element).hasClass(ClassName.DISABLED) || $(this._menu).hasClass(ClassName.SHOW)) {
+ return
+ }
+
const relatedTarget = {
relatedTarget: this._element
}
const showEvent = $.Event(Event.SHOW, relatedTarget)
+ const parent = Dropdown._getParentFromElement(this._element)
$(parent).trigger(showEvent)
@@ -145,7 +155,7 @@ class Dropdown {
}
// Disable totally Popper.js for Dropdown in Navbar
- if (!this._inNavbar) {
+ if (!this._inNavbar && usePopper) {
/**
* Check for Popper dependency
* Popper - https://popper.js.org
@@ -194,29 +204,6 @@ class Dropdown {
.trigger($.Event(Event.SHOWN, relatedTarget))
}
- show() {
- if (this._element.disabled || $(this._element).hasClass(ClassName.DISABLED) || $(this._menu).hasClass(ClassName.SHOW)) {
- return
- }
-
- const relatedTarget = {
- relatedTarget: this._element
- }
- const showEvent = $.Event(Event.SHOW, relatedTarget)
- const parent = Dropdown._getParentFromElement(this._element)
-
- $(parent).trigger(showEvent)
-
- if (showEvent.isDefaultPrevented()) {
- return
- }
-
- $(this._menu).toggleClass(ClassName.SHOW)
- $(parent)
- .toggleClass(ClassName.SHOW)
- .trigger($.Event(Event.SHOWN, relatedTarget))
- }
-
hide() {
if (this._element.disabled || $(this._element).hasClass(ClassName.DISABLED) || !$(this._menu).hasClass(ClassName.SHOW)) {
return
@@ -234,6 +221,10 @@ class Dropdown {
return
}
+ if (this._popper) {
+ this._popper.destroy()
+ }
+
$(this._menu).toggleClass(ClassName.SHOW)
$(parent)
.toggleClass(ClassName.SHOW)
@@ -359,7 +350,10 @@ class Dropdown {
}
}
- return popperConfig
+ return {
+ ...popperConfig,
+ ...this._config.popperConfig
+ }
}
// Static
@@ -431,6 +425,10 @@ class Dropdown {
toggles[i].setAttribute('aria-expanded', 'false')
+ if (context._popper) {
+ context._popper.destroy()
+ }
+
$(dropdownMenu).removeClass(ClassName.SHOW)
$(parent)
.removeClass(ClassName.SHOW)
@@ -475,6 +473,10 @@ class Dropdown {
const parent = Dropdown._getParentFromElement(this)
const isActive = $(parent).hasClass(ClassName.SHOW)
+ if (!isActive && event.which === ESCAPE_KEYCODE) {
+ return
+ }
+
if (!isActive || isActive && (event.which === ESCAPE_KEYCODE || event.which === SPACE_KEYCODE)) {
if (event.which === ESCAPE_KEYCODE) {
const toggle = parent.querySelector(Selector.DATA_TOGGLE)
@@ -486,6 +488,7 @@ class Dropdown {
}
const items = [].slice.call(parent.querySelectorAll(Selector.VISIBLE_ITEMS))
+ .filter((item) => $(item).is(':visible'))
if (items.length === 0) {
return