diff options
| author | XhmikosR <[email protected]> | 2021-10-13 15:19:28 +0300 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-10-13 15:19:28 +0300 |
| commit | e8f702666f285a3e69866ed1f8d29fa6eaaaeabb (patch) | |
| tree | 944b2dc894f49f8278d41d096e4388e9ac83157b /js/src/util/focustrap.js | |
| parent | db44392bda22f3d5319d2880c992f76d27d2a60c (diff) | |
| download | bootstrap-e8f702666f285a3e69866ed1f8d29fa6eaaaeabb.tar.xz bootstrap-e8f702666f285a3e69866ed1f8d29fa6eaaaeabb.zip | |
JS: minor refactoring (#35183)
* add missing comments
* shorten block comments
* reorder constants
* reorder public/private methods
* sort exports alphabetically in util/index.js
* fix a couple of typos
Diffstat (limited to 'js/src/util/focustrap.js')
| -rw-r--r-- | js/src/util/focustrap.js | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/js/src/util/focustrap.js b/js/src/util/focustrap.js index 44d5f47eb..a1975f489 100644 --- a/js/src/util/focustrap.js +++ b/js/src/util/focustrap.js @@ -9,15 +9,9 @@ import EventHandler from '../dom/event-handler' import SelectorEngine from '../dom/selector-engine' import { typeCheckConfig } from './index' -const Default = { - trapElement: null, // The element to trap focus inside of - autofocus: true -} - -const DefaultType = { - trapElement: 'element', - autofocus: 'boolean' -} +/** + * Constants + */ const NAME = 'focustrap' const DATA_KEY = 'bs.focustrap' @@ -29,6 +23,20 @@ const TAB_KEY = 'Tab' const TAB_NAV_FORWARD = 'forward' const TAB_NAV_BACKWARD = 'backward' +const Default = { + trapElement: null, // The element to trap focus inside of + autofocus: true +} + +const DefaultType = { + trapElement: 'element', + autofocus: 'boolean' +} + +/** + * Class definition + */ + class FocusTrap { constructor(config) { this._config = this._getConfig(config) @@ -36,6 +44,7 @@ class FocusTrap { this._lastTabNavDirection = null } + // Public activate() { const { trapElement, autofocus } = this._config @@ -64,7 +73,6 @@ class FocusTrap { } // Private - _handleFocusin(event) { const { target } = event const { trapElement } = this._config |
