diff options
| author | Pierre-Denis Vanduynslager <[email protected]> | 2017-01-14 21:42:24 -0500 |
|---|---|---|
| committer | Bardi Harborow <[email protected]> | 2017-01-15 13:42:24 +1100 |
| commit | c80e13a48a50caecc3e0c7b2904655e8bdc95d9c (patch) | |
| tree | e273aad7bc37107da97914da33a953991f56f537 /js/src | |
| parent | 25f81e1fe6da99fac2c3dd18b92d8f6305dca4af (diff) | |
| download | bootstrap-c80e13a48a50caecc3e0c7b2904655e8bdc95d9c.tar.xz bootstrap-c80e13a48a50caecc3e0c7b2904655e8bdc95d9c.zip | |
Use existing keycode constants in dropdown. (#21697)
Diffstat (limited to 'js/src')
| -rw-r--r-- | js/src/dropdown.js | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/js/src/dropdown.js b/js/src/dropdown.js index 36305df46..1660d4257 100644 --- a/js/src/dropdown.js +++ b/js/src/dropdown.js @@ -24,9 +24,11 @@ const Dropdown = (($) => { const DATA_API_KEY = '.data-api' const JQUERY_NO_CONFLICT = $.fn[NAME] const ESCAPE_KEYCODE = 27 // KeyboardEvent.which value for Escape (Esc) key + const SPACE_KEYCODE = 32 // KeyboardEvent.which value for space key const ARROW_UP_KEYCODE = 38 // KeyboardEvent.which value for up arrow key const ARROW_DOWN_KEYCODE = 40 // KeyboardEvent.which value for down arrow key const RIGHT_MOUSE_BUTTON_WHICH = 3 // MouseEvent.which value for the right button (assuming a right-handed mouse) + const REGEXP_KEYDOWN = new RegExp(`${ARROW_UP_KEYCODE}|${ARROW_DOWN_KEYCODE}|${ESCAPE_KEYCODE}|${SPACE_KEYCODE}`) const Event = { HIDE : `hide${EVENT_KEY}`, @@ -213,7 +215,7 @@ const Dropdown = (($) => { } static _dataApiKeydownHandler(event) { - if (!/(38|40|27|32)/.test(event.which) || + if (!REGEXP_KEYDOWN.test(event.which) || /input|textarea/i.test(event.target.tagName)) { return } |
