aboutsummaryrefslogtreecommitdiff
path: root/js/src/util/focustrap.js
diff options
context:
space:
mode:
authorPriyansh <[email protected]>2021-11-28 14:27:57 -0500
committerGitHub <[email protected]>2021-11-28 14:27:57 -0500
commitd53094ec16ba385faae2973ddee648698b32ab24 (patch)
tree9fe907f4f5a4ed57fff915526f36eca9dd05f07e /js/src/util/focustrap.js
parent52cd86f8710f8049a744b5bcb9f4a7ce19114b6e (diff)
parent5290080d4df3047d04c8a232bca5dc7f8eaa4bc6 (diff)
downloadbootstrap-d53094ec16ba385faae2973ddee648698b32ab24.tar.xz
bootstrap-d53094ec16ba385faae2973ddee648698b32ab24.zip
Merge branch 'twbs:main' into main
Diffstat (limited to 'js/src/util/focustrap.js')
-rw-r--r--js/src/util/focustrap.js30
1 files changed, 19 insertions, 11 deletions
diff --git a/js/src/util/focustrap.js b/js/src/util/focustrap.js
index 500a5b3bc..a1975f489 100644
--- a/js/src/util/focustrap.js
+++ b/js/src/util/focustrap.js
@@ -1,6 +1,6 @@
/**
* --------------------------------------------------------------------------
- * Bootstrap (v5.1.2): util/focustrap.js
+ * Bootstrap (v5.1.3): util/focustrap.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
@@ -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