aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/twbs/bootstrap/js/src/base-component.js
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/twbs/bootstrap/js/src/base-component.js')
-rw-r--r--vendor/twbs/bootstrap/js/src/base-component.js46
1 files changed, 28 insertions, 18 deletions
diff --git a/vendor/twbs/bootstrap/js/src/base-component.js b/vendor/twbs/bootstrap/js/src/base-component.js
index 28cf877fb..b5008b3a2 100644
--- a/vendor/twbs/bootstrap/js/src/base-component.js
+++ b/vendor/twbs/bootstrap/js/src/base-component.js
@@ -1,52 +1,62 @@
/**
* --------------------------------------------------------------------------
- * Bootstrap (v5.1.3): base-component.js
+ * Bootstrap (v5.2.0): base-component.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
import Data from './dom/data'
-import {
- executeAfterTransition,
- getElement
-} from './util/index'
+import { executeAfterTransition, getElement } from './util/index'
import EventHandler from './dom/event-handler'
+import Config from './util/config'
/**
- * ------------------------------------------------------------------------
* Constants
- * ------------------------------------------------------------------------
*/
-const VERSION = '5.1.3'
+const VERSION = '5.2.0'
-class BaseComponent {
- constructor(element) {
- element = getElement(element)
+/**
+ * Class definition
+ */
+class BaseComponent extends Config {
+ constructor(element, config) {
+ super()
+
+ element = getElement(element)
if (!element) {
return
}
this._element = element
+ this._config = this._getConfig(config)
+
Data.set(this._element, this.constructor.DATA_KEY, this)
}
+ // Public
dispose() {
Data.remove(this._element, this.constructor.DATA_KEY)
EventHandler.off(this._element, this.constructor.EVENT_KEY)
- Object.getOwnPropertyNames(this).forEach(propertyName => {
+ for (const propertyName of Object.getOwnPropertyNames(this)) {
this[propertyName] = null
- })
+ }
}
_queueCallback(callback, element, isAnimated = true) {
executeAfterTransition(callback, element, isAnimated)
}
- /** Static */
+ _getConfig(config) {
+ config = this._mergeConfigObj(config, this._element)
+ config = this._configAfterMerge(config)
+ this._typeCheckConfig(config)
+ return config
+ }
+ // Static
static getInstance(element) {
return Data.get(getElement(element), this.DATA_KEY)
}
@@ -59,10 +69,6 @@ class BaseComponent {
return VERSION
}
- static get NAME() {
- throw new Error('You have to implement the static method "NAME", for each component!')
- }
-
static get DATA_KEY() {
return `bs.${this.NAME}`
}
@@ -70,6 +76,10 @@ class BaseComponent {
static get EVENT_KEY() {
return `.${this.DATA_KEY}`
}
+
+ static eventName(name) {
+ return `${name}${this.EVENT_KEY}`
+ }
}
export default BaseComponent