aboutsummaryrefslogtreecommitdiff
path: root/js/src/util/focustrap.js
diff options
context:
space:
mode:
authorGeoSot <[email protected]>2021-12-10 18:18:18 +0200
committerGitHub <[email protected]>2021-12-10 18:18:18 +0200
commit886b940796b3595a03b44230ca8b78197c5ee1c5 (patch)
tree6b37d0208ae9fd9816e052572ab3496095cc88b6 /js/src/util/focustrap.js
parent68f226750db03bc26ed5ead6bb074804a4f63853 (diff)
downloadbootstrap-886b940796b3595a03b44230ca8b78197c5ee1c5.tar.xz
bootstrap-886b940796b3595a03b44230ca8b78197c5ee1c5.zip
Extract Component config functionality to a separate class (#33872)
Co-authored-by: XhmikosR <[email protected]>
Diffstat (limited to 'js/src/util/focustrap.js')
-rw-r--r--js/src/util/focustrap.js27
1 files changed, 16 insertions, 11 deletions
diff --git a/js/src/util/focustrap.js b/js/src/util/focustrap.js
index a1975f489..46727ecf8 100644
--- a/js/src/util/focustrap.js
+++ b/js/src/util/focustrap.js
@@ -7,7 +7,7 @@
import EventHandler from '../dom/event-handler'
import SelectorEngine from '../dom/selector-engine'
-import { typeCheckConfig } from './index'
+import Config from './config'
/**
* Constants
@@ -37,13 +37,27 @@ const DefaultType = {
* Class definition
*/
-class FocusTrap {
+class FocusTrap extends Config {
constructor(config) {
+ super()
this._config = this._getConfig(config)
this._isActive = false
this._lastTabNavDirection = null
}
+ // Getters
+ static get Default() {
+ return Default
+ }
+
+ static get DefaultType() {
+ return DefaultType
+ }
+
+ static get NAME() {
+ return NAME
+ }
+
// Public
activate() {
const { trapElement, autofocus } = this._config
@@ -99,15 +113,6 @@ class FocusTrap {
this._lastTabNavDirection = event.shiftKey ? TAB_NAV_BACKWARD : TAB_NAV_FORWARD
}
-
- _getConfig(config) {
- config = {
- ...Default,
- ...(typeof config === 'object' ? config : {})
- }
- typeCheckConfig(NAME, config, DefaultType)
- return config
- }
}
export default FocusTrap