1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-09-26 13:29:06 +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

@@ -10,11 +10,9 @@ import {
getElement,
getElementFromSelector,
getSelectorFromElement,
reflow,
typeCheckConfig
reflow
} from './util/index'
import EventHandler from './dom/event-handler'
import Manipulator from './dom/manipulator'
import SelectorEngine from './dom/selector-engine'
import BaseComponent from './base-component'
@@ -62,10 +60,9 @@ const DefaultType = {
class Collapse extends BaseComponent {
constructor(element, config) {
super(element)
super(element, config)
this._isTransitioning = false
this._config = this._getConfig(config)
this._triggerArray = []
const toggleList = SelectorEngine.find(SELECTOR_DATA_TOGGLE)
@@ -96,6 +93,10 @@ class Collapse extends BaseComponent {
return Default
}
static get DefaultType() {
return DefaultType
}
static get NAME() {
return NAME
}
@@ -210,15 +211,9 @@ class Collapse extends BaseComponent {
}
// Private
_getConfig(config) {
config = {
...Default,
...Manipulator.getDataAttributes(this._element),
...config
}
_configAfterMerge(config) {
config.toggle = Boolean(config.toggle) // Coerce string values
config.parent = getElement(config.parent)
typeCheckConfig(NAME, config, DefaultType)
return config
}