From 886b940796b3595a03b44230ca8b78197c5ee1c5 Mon Sep 17 00:00:00 2001 From: GeoSot Date: Fri, 10 Dec 2021 18:18:18 +0200 Subject: Extract Component config functionality to a separate class (#33872) Co-authored-by: XhmikosR --- js/src/util/focustrap.js | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'js/src/util/focustrap.js') 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 -- cgit v1.2.3 From 0c3dfe104b520d6ce466f265bf60c6d74785972e Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Sat, 9 Oct 2021 21:49:49 +0300 Subject: Remove a few unneeded variables --- js/src/util/focustrap.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'js/src/util/focustrap.js') diff --git a/js/src/util/focustrap.js b/js/src/util/focustrap.js index 46727ecf8..88fd16b10 100644 --- a/js/src/util/focustrap.js +++ b/js/src/util/focustrap.js @@ -60,14 +60,12 @@ class FocusTrap extends Config { // Public activate() { - const { trapElement, autofocus } = this._config - if (this._isActive) { return } - if (autofocus) { - trapElement.focus() + if (this._config.autofocus) { + this._config.trapElement.focus() } EventHandler.off(document, EVENT_KEY) // guard against infinite focus loop @@ -88,10 +86,9 @@ class FocusTrap extends Config { // Private _handleFocusin(event) { - const { target } = event const { trapElement } = this._config - if (target === document || target === trapElement || trapElement.contains(target)) { + if (event.target === document || event.target === trapElement || trapElement.contains(event.target)) { return } -- cgit v1.2.3 From f7e8ca91e03165abb82d4c82555dc4ef96340cc9 Mon Sep 17 00:00:00 2001 From: Mark Otto Date: Fri, 6 May 2022 23:57:58 +0300 Subject: Prepare v5.2.0-beta1 --- js/src/util/focustrap.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/src/util/focustrap.js') diff --git a/js/src/util/focustrap.js b/js/src/util/focustrap.js index 88fd16b10..40509c1ba 100644 --- a/js/src/util/focustrap.js +++ b/js/src/util/focustrap.js @@ -1,6 +1,6 @@ /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): util/focustrap.js + * Bootstrap (v5.2.0-beta1): util/focustrap.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ -- cgit v1.2.3 From c137d11aa2df111e2a42bc42295576fdd366fd68 Mon Sep 17 00:00:00 2001 From: "louismaxime.piton" Date: Thu, 19 May 2022 15:35:44 +0200 Subject: Re-ordering js default objects --- js/src/util/focustrap.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'js/src/util/focustrap.js') diff --git a/js/src/util/focustrap.js b/js/src/util/focustrap.js index 40509c1ba..51dd19f22 100644 --- a/js/src/util/focustrap.js +++ b/js/src/util/focustrap.js @@ -24,13 +24,13 @@ const TAB_NAV_FORWARD = 'forward' const TAB_NAV_BACKWARD = 'backward' const Default = { - trapElement: null, // The element to trap focus inside of - autofocus: true + autofocus: true, + trapElement: null // The element to trap focus inside of } const DefaultType = { - trapElement: 'element', - autofocus: 'boolean' + autofocus: 'boolean', + trapElement: 'element' } /** -- cgit v1.2.3 From edf9c40956d19e6ab3f9151bfe0dfac6be06fa21 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Tue, 19 Jul 2022 18:43:58 +0300 Subject: Release v5.2.0 (#36768) * Bump version to 5.2.0 * Dist * Update masthead.html --- js/src/util/focustrap.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/src/util/focustrap.js') diff --git a/js/src/util/focustrap.js b/js/src/util/focustrap.js index 51dd19f22..5ffc9fe1c 100644 --- a/js/src/util/focustrap.js +++ b/js/src/util/focustrap.js @@ -1,6 +1,6 @@ /** * -------------------------------------------------------------------------- - * Bootstrap (v5.2.0-beta1): util/focustrap.js + * Bootstrap (v5.2.0): util/focustrap.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ -- cgit v1.2.3 From 23e50829f958ea1d741d63e2781716be037e4644 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Wed, 7 Sep 2022 18:31:39 +0300 Subject: Release v5.2.1 (#37098) * Bump version to v5.2.1. * Dist --- js/src/util/focustrap.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/src/util/focustrap.js') diff --git a/js/src/util/focustrap.js b/js/src/util/focustrap.js index 5ffc9fe1c..262832782 100644 --- a/js/src/util/focustrap.js +++ b/js/src/util/focustrap.js @@ -1,6 +1,6 @@ /** * -------------------------------------------------------------------------- - * Bootstrap (v5.2.0): util/focustrap.js + * Bootstrap (v5.2.1): util/focustrap.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ -- cgit v1.2.3 From 961d5ff9844372a4e294980c667bbe7e0651cdeb Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Mon, 3 Oct 2022 10:44:02 +0300 Subject: Release v5.2.2 (#37236) * Bump version to v5.2.2 * Dist --- js/src/util/focustrap.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/src/util/focustrap.js') diff --git a/js/src/util/focustrap.js b/js/src/util/focustrap.js index 262832782..01ac76683 100644 --- a/js/src/util/focustrap.js +++ b/js/src/util/focustrap.js @@ -1,6 +1,6 @@ /** * -------------------------------------------------------------------------- - * Bootstrap (v5.2.1): util/focustrap.js + * Bootstrap (v5.2.2): util/focustrap.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ -- cgit v1.2.3 From aa9d32dd153ed16943ad8be5e8795afaad24d0cf Mon Sep 17 00:00:00 2001 From: GeoSot Date: Wed, 26 Oct 2022 08:26:51 +0300 Subject: Use explicit imports in our javascript source files (#36854) --- js/src/util/focustrap.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'js/src/util/focustrap.js') diff --git a/js/src/util/focustrap.js b/js/src/util/focustrap.js index 01ac76683..b03d46136 100644 --- a/js/src/util/focustrap.js +++ b/js/src/util/focustrap.js @@ -5,9 +5,9 @@ * -------------------------------------------------------------------------- */ -import EventHandler from '../dom/event-handler' -import SelectorEngine from '../dom/selector-engine' -import Config from './config' +import EventHandler from '../dom/event-handler.js' +import SelectorEngine from '../dom/selector-engine.js' +import Config from './config.js' /** * Constants -- cgit v1.2.3 From 39589472f709ddf7d614ffd4f0ab1a50e542ac91 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Mon, 21 Nov 2022 20:15:33 +0200 Subject: Bump version to 5.2.3 --- js/src/util/focustrap.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/src/util/focustrap.js') diff --git a/js/src/util/focustrap.js b/js/src/util/focustrap.js index 01ac76683..ef6916679 100644 --- a/js/src/util/focustrap.js +++ b/js/src/util/focustrap.js @@ -1,6 +1,6 @@ /** * -------------------------------------------------------------------------- - * Bootstrap (v5.2.2): util/focustrap.js + * Bootstrap (v5.2.3): util/focustrap.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ -- cgit v1.2.3 From cf9454caa00872899215603e5e036d9a824b1b11 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Sat, 24 Dec 2022 18:37:22 +0200 Subject: Release v5.3.0-alpha1 (#37661) * Bump version to 5.3.0-alpha1 * Dist * Add docs versions updates * Update note in homepage hero Co-authored-by: Mark Otto --- js/src/util/focustrap.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/src/util/focustrap.js') diff --git a/js/src/util/focustrap.js b/js/src/util/focustrap.js index 1736c4f7c..2f189585a 100644 --- a/js/src/util/focustrap.js +++ b/js/src/util/focustrap.js @@ -1,6 +1,6 @@ /** * -------------------------------------------------------------------------- - * Bootstrap (v5.2.3): util/focustrap.js + * Bootstrap (v5.3.0-alpha1): util/focustrap.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ -- cgit v1.2.3 From ab049cd4a02650ca95d490217f93bd628f9295a6 Mon Sep 17 00:00:00 2001 From: GeoSot Date: Wed, 22 Mar 2023 09:12:33 +0200 Subject: Remove version comment from JavaScript src files (#38294) --- js/src/util/focustrap.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/src/util/focustrap.js') diff --git a/js/src/util/focustrap.js b/js/src/util/focustrap.js index 2f189585a..158f3d184 100644 --- a/js/src/util/focustrap.js +++ b/js/src/util/focustrap.js @@ -1,6 +1,6 @@ /** * -------------------------------------------------------------------------- - * Bootstrap (v5.3.0-alpha1): util/focustrap.js + * Bootstrap util/focustrap.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ -- cgit v1.2.3