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:
@@ -12,8 +12,7 @@ import {
|
||||
isRTL,
|
||||
isVisible,
|
||||
reflow,
|
||||
triggerTransitionEnd,
|
||||
typeCheckConfig
|
||||
triggerTransitionEnd
|
||||
} from './util/index'
|
||||
import EventHandler from './dom/event-handler'
|
||||
import Manipulator from './dom/manipulator'
|
||||
@@ -95,7 +94,7 @@ const DefaultType = {
|
||||
|
||||
class Carousel extends BaseComponent {
|
||||
constructor(element, config) {
|
||||
super(element)
|
||||
super(element, config)
|
||||
|
||||
this._items = null
|
||||
this._interval = null
|
||||
@@ -105,7 +104,6 @@ class Carousel extends BaseComponent {
|
||||
this.touchTimeout = null
|
||||
this._swipeHelper = null
|
||||
|
||||
this._config = this._getConfig(config)
|
||||
this._indicatorsElement = SelectorEngine.findOne(SELECTOR_INDICATORS, this._element)
|
||||
this._addEventListeners()
|
||||
}
|
||||
@@ -115,6 +113,10 @@ class Carousel extends BaseComponent {
|
||||
return Default
|
||||
}
|
||||
|
||||
static get DefaultType() {
|
||||
return DefaultType
|
||||
}
|
||||
|
||||
static get NAME() {
|
||||
return NAME
|
||||
}
|
||||
@@ -205,16 +207,6 @@ class Carousel extends BaseComponent {
|
||||
}
|
||||
|
||||
// Private
|
||||
_getConfig(config) {
|
||||
config = {
|
||||
...Default,
|
||||
...Manipulator.getDataAttributes(this._element),
|
||||
...(typeof config === 'object' ? config : {})
|
||||
}
|
||||
typeCheckConfig(NAME, config, DefaultType)
|
||||
return config
|
||||
}
|
||||
|
||||
_addEventListeners() {
|
||||
if (this._config.keyboard) {
|
||||
EventHandler.on(this._element, EVENT_KEYDOWN, event => this._keydown(event))
|
||||
|
Reference in New Issue
Block a user