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
path: root/js
diff options
context:
space:
mode:
authoralpadev <2838324+alpadev@users.noreply.github.com>2021-04-11 18:34:46 +0300
committerGitHub <noreply@github.com>2021-04-11 18:34:46 +0300
commitad10f00d5e073f60b8d86d03812742b97037c336 (patch)
tree631cd7622af3eee5183baf9f01d877d7a4f7587e /js
parent566451230f5c87c3d7515af02995895df610b8ac (diff)
refactor: make static `selectMenuItem` method private (#33589)
Diffstat (limited to 'js')
-rw-r--r--js/src/dropdown.js52
1 files changed, 26 insertions, 26 deletions
diff --git a/js/src/dropdown.js b/js/src/dropdown.js
index b126d3196a..ae440e4724 100644
--- a/js/src/dropdown.js
+++ b/js/src/dropdown.js
@@ -356,6 +356,31 @@ class Dropdown extends BaseComponent {
}
}
+ _selectMenuItem(event) {
+ const items = SelectorEngine.find(SELECTOR_VISIBLE_ITEMS, this._menu).filter(isVisible)
+
+ if (!items.length) {
+ return
+ }
+
+ let index = items.indexOf(event.target)
+
+ // Up
+ if (event.key === ARROW_UP_KEY && index > 0) {
+ index--
+ }
+
+ // Down
+ if (event.key === ARROW_DOWN_KEY && index < items.length - 1) {
+ index++
+ }
+
+ // index is -1 if the first keydown is an ArrowUp
+ index = index === -1 ? 0 : index
+
+ items[index].focus()
+ }
+
// Static
static dropdownInterface(element, config) {
@@ -449,31 +474,6 @@ class Dropdown extends BaseComponent {
}
}
- static selectMenuItem(parent, event) {
- const items = SelectorEngine.find(SELECTOR_VISIBLE_ITEMS, parent).filter(isVisible)
-
- if (!items.length) {
- return
- }
-
- let index = items.indexOf(event.target)
-
- // Up
- if (event.key === ARROW_UP_KEY && index > 0) {
- index--
- }
-
- // Down
- if (event.key === ARROW_DOWN_KEY && index < items.length - 1) {
- index++
- }
-
- // index is -1 if the first keydown is an ArrowUp
- index = index === -1 ? 0 : index
-
- items[index].focus()
- }
-
static getParentFromElement(element) {
return getElementFromSelector(element) || element.parentNode
}
@@ -525,7 +525,7 @@ class Dropdown extends BaseComponent {
return
}
- Dropdown.selectMenuItem(Dropdown.getParentFromElement(this), event)
+ Dropdown.getInstance(getToggleButton())._selectMenuItem(event)
}
}