1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-09-30 07:19:13 +02:00

Extract Component config functionality to a separate class (#33872)

Co-authored-by: XhmikosR <xhmikosr@gmail.com>
This commit is contained in:
GeoSot
2021-12-10 18:18:18 +02:00
committed by GitHub
parent 68f226750d
commit 886b940796
18 changed files with 283 additions and 240 deletions

View File

@@ -5,9 +5,8 @@
* --------------------------------------------------------------------------
*/
import { defineJQueryPlugin, reflow, typeCheckConfig } from './util/index'
import { defineJQueryPlugin, reflow } from './util/index'
import EventHandler from './dom/event-handler'
import Manipulator from './dom/manipulator'
import BaseComponent from './base-component'
import { enableDismissTrigger } from './util/component-functions'
@@ -51,9 +50,8 @@ const Default = {
class Toast extends BaseComponent {
constructor(element, config) {
super(element)
super(element, config)
this._config = this._getConfig(config)
this._timeout = null
this._hasMouseInteraction = false
this._hasKeyboardInteraction = false
@@ -61,14 +59,14 @@ class Toast extends BaseComponent {
}
// Getters
static get DefaultType() {
return DefaultType
}
static get Default() {
return Default
}
static get DefaultType() {
return DefaultType
}
static get NAME() {
return NAME
}
@@ -133,17 +131,6 @@ class Toast extends BaseComponent {
}
// Private
_getConfig(config) {
config = {
...Default,
...Manipulator.getDataAttributes(this._element),
...(typeof config === 'object' && config ? config : {})
}
typeCheckConfig(NAME, config, this.constructor.DefaultType)
return config
}
_maybeScheduleHide() {
if (!this._config.autohide) {