aboutsummaryrefslogtreecommitdiff
path: root/js/src/dropdown.js
diff options
context:
space:
mode:
authorMark Otto <[email protected]>2015-08-18 20:25:48 -0700
committerMark Otto <[email protected]>2015-08-18 20:25:48 -0700
commit1c19ded8c14cc9caca8ca2992834e2900dbbb4e5 (patch)
treeaecfad1ba54e89b6db1f72f20c991784768399e5 /js/src/dropdown.js
parent0df8fae72508fd9291ccce1fb915e7eac4f83a95 (diff)
parent8cfde5ef29756a433645c61b2ba8fec63caada78 (diff)
downloadbootstrap-1c19ded8c14cc9caca8ca2992834e2900dbbb4e5.tar.xz
bootstrap-1c19ded8c14cc9caca8ca2992834e2900dbbb4e5.zip
Merge branch 'v4' of https://github.com/twbs/derpstrap into v4
Diffstat (limited to 'js/src/dropdown.js')
-rw-r--r--js/src/dropdown.js24
1 files changed, 16 insertions, 8 deletions
diff --git a/js/src/dropdown.js b/js/src/dropdown.js
index 1c4866dc2..734e64312 100644
--- a/js/src/dropdown.js
+++ b/js/src/dropdown.js
@@ -78,7 +78,7 @@ const Dropdown = (($) => {
toggle() {
if (this.disabled || $(this).hasClass(ClassName.DISABLED)) {
- return
+ return false
}
let parent = Dropdown._getParentFromElement(this)
@@ -106,7 +106,7 @@ const Dropdown = (($) => {
$(parent).trigger(showEvent)
if (showEvent.isDefaultPrevented()) {
- return
+ return false
}
this.focus()
@@ -239,9 +239,17 @@ const Dropdown = (($) => {
let index = items.indexOf(event.target)
- if (event.which === 38 && index > 0) index-- // up
- if (event.which === 40 && index < items.length - 1) index++ // down
- if (!~index) index = 0
+ if (event.which === 38 && index > 0) { // up
+ index--
+ }
+
+ if (event.which === 40 && index < items.length - 1) { // down
+ index++
+ }
+
+ if (!~index) {
+ index = 0
+ }
items[index].focus()
}
@@ -261,9 +269,9 @@ const Dropdown = (($) => {
.on(Event.KEYDOWN_DATA_API, Selector.ROLE_LISTBOX, Dropdown._dataApiKeydownHandler)
.on(Event.CLICK_DATA_API, Dropdown._clearMenus)
.on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, Dropdown.prototype.toggle)
- .on(Event.CLICK_DATA_API, Selector.FORM_CHILD, function (e) {
- e.stopPropagation()
- })
+ .on(Event.CLICK_DATA_API, Selector.FORM_CHILD, (e) => {
+ e.stopPropagation()
+ })
/**