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

@@ -12,8 +12,7 @@ import {
getElement,
getUID,
isRTL,
noop,
typeCheckConfig
noop
} from './util/index'
import { DefaultAllowlist } from './util/sanitizer'
import EventHandler from './dom/event-handler'
@@ -140,6 +139,10 @@ class Tooltip extends BaseComponent {
return Default
}
static get DefaultType() {
return DefaultType
}
static get NAME() {
return NAME
}
@@ -148,10 +151,6 @@ class Tooltip extends BaseComponent {
return Event
}
static get DefaultType() {
return DefaultType
}
// Public
enable() {
this._isEnabled = true
@@ -571,11 +570,16 @@ class Tooltip extends BaseComponent {
}
config = {
...this.constructor.Default,
...dataAttributes,
...(typeof config === 'object' && config ? config : {})
}
config = this._mergeConfigObj(config)
config = this._configAfterMerge(config)
this._typeCheckConfig(config)
return config
}
_configAfterMerge(config) {
config.container = config.container === false ? document.body : getElement(config.container)
if (typeof config.delay === 'number') {
@@ -595,7 +599,6 @@ class Tooltip extends BaseComponent {
config.content = config.content.toString()
}
typeCheckConfig(NAME, config, this.constructor.DefaultType)
return config
}