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:
authorGeoSot <geo.sotis@gmail.com>2022-09-27 10:39:11 +0300
committerGitHub <noreply@github.com>2022-09-27 10:39:11 +0300
commit597c4023141dc48868889b85676b2d7269411d23 (patch)
treee4ab90fa59bd98daaaa69942c3564706b962268b /js/src/dropdown.js
parente77367dddc1a523b6a7197735dbef7cd63d62fe9 (diff)
Dropdown: fix case with invalid markup (#37190)
This fixes a backward incompatible change in v5.2.1 where `.drodown-toggle` isn't present in the markup.
Diffstat (limited to 'js/src/dropdown.js')
-rw-r--r--js/src/dropdown.js11
1 files changed, 9 insertions, 2 deletions
diff --git a/js/src/dropdown.js b/js/src/dropdown.js
index 607ab27ba7..f8dafc21bd 100644
--- a/js/src/dropdown.js
+++ b/js/src/dropdown.js
@@ -96,7 +96,9 @@ class Dropdown extends BaseComponent {
this._popper = null
this._parent = this._element.parentNode // dropdown wrapper
// todo: v6 revert #37011 & change markup https://getbootstrap.com/docs/5.2/forms/input-group/
- this._menu = SelectorEngine.next(this._element, SELECTOR_MENU)[0] || SelectorEngine.prev(this._element, SELECTOR_MENU)[0]
+ this._menu = SelectorEngine.next(this._element, SELECTOR_MENU)[0] ||
+ SelectorEngine.prev(this._element, SELECTOR_MENU)[0] ||
+ SelectorEngine.findOne(SELECTOR_MENU, this._parent)
this._inNavbar = this._detectNavbar()
}
@@ -407,7 +409,12 @@ class Dropdown extends BaseComponent {
event.preventDefault()
// todo: v6 revert #37011 & change markup https://getbootstrap.com/docs/5.2/forms/input-group/
- const getToggleButton = this.matches(SELECTOR_DATA_TOGGLE) ? this : SelectorEngine.prev(this, SELECTOR_DATA_TOGGLE)[0] || SelectorEngine.next(this, SELECTOR_DATA_TOGGLE)[0]
+ const getToggleButton = this.matches(SELECTOR_DATA_TOGGLE) ?
+ this :
+ (SelectorEngine.prev(this, SELECTOR_DATA_TOGGLE)[0] ||
+ SelectorEngine.next(this, SELECTOR_DATA_TOGGLE)[0] ||
+ SelectorEngine.findOne(SELECTOR_DATA_TOGGLE, event.delegateTarget.parentNode))
+
const instance = Dropdown.getOrCreateInstance(getToggleButton)
if (isUpOrDownEvent) {