0
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-03-15 15:29:22 +01:00

streamline _getConfig & interface

This commit is contained in:
GeoSot 2021-06-10 01:08:07 +03:00 committed by XhmikosR
parent c6c0bbb0b6
commit 2ad0a4a9fd

View File

@ -259,6 +259,7 @@ class Collapse extends BaseComponent {
_getConfig(config) { _getConfig(config) {
config = { config = {
...Default, ...Default,
...Manipulator.getDataAttributes(this._element),
...config ...config
} }
config.toggle = Boolean(config.toggle) // Coerce string values config.toggle = Boolean(config.toggle) // Coerce string values
@ -311,20 +312,12 @@ class Collapse extends BaseComponent {
// Static // Static
static collapseInterface(element, config) { static collapseInterface(element, config) {
let data = Collapse.getInstance(element) const _config = {}
const _config = { if (typeof config === 'string' && /show|hide/.test(config)) {
...Default,
...Manipulator.getDataAttributes(element),
...(typeof config === 'object' && config ? config : {})
}
if (!data && _config.toggle && typeof config === 'string' && /show|hide/.test(config)) {
_config.toggle = false _config.toggle = false
} }
if (!data) { const data = Collapse.getOrCreateInstance(element, _config)
data = new Collapse(element, _config)
}
if (typeof config === 'string') { if (typeof config === 'string') {
if (typeof data[config] === 'undefined') { if (typeof data[config] === 'undefined') {