1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-18 03:11:19 +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

@@ -15,8 +15,7 @@ import {
isElement,
isRTL,
isVisible,
noop,
typeCheckConfig
noop
} from './util/index'
import EventHandler from './dom/event-handler'
import Manipulator from './dom/manipulator'
@@ -88,10 +87,9 @@ const DefaultType = {
class Dropdown extends BaseComponent {
constructor(element, config) {
super(element)
super(element, config)
this._popper = null
this._config = this._getConfig(config)
this._menu = this._getMenuElement()
this._inNavbar = this._detectNavbar()
}
@@ -205,13 +203,7 @@ class Dropdown extends BaseComponent {
}
_getConfig(config) {
config = {
...this.constructor.Default,
...Manipulator.getDataAttributes(this._element),
...config
}
typeCheckConfig(NAME, config, this.constructor.DefaultType)
config = super._getConfig(config)
if (typeof config.reference === 'object' && !isElement(config.reference) &&
typeof config.reference.getBoundingClientRect !== 'function'