0
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-01-30 22:52:24 +01:00

Carousel: cleanup jQueryInterface

Drop chained else ifs and unused variable.

Since we were checking for `typeof config === 'string'` in both places, action was never `_config.slide`.
This commit is contained in:
GeoSot 2022-03-02 00:57:28 +02:00 committed by XhmikosR
parent 21fa2cfc12
commit e77ae50311

View File

@ -442,17 +442,21 @@ class Carousel extends BaseComponent {
}
}
const action = typeof config === 'string' ? config : _config.slide
if (typeof config === 'number') {
data.to(config)
} else if (typeof action === 'string') {
if (typeof data[action] === 'undefined') {
throw new TypeError(`No method named "${action}"`)
return
}
data[action]()
} else if (_config.interval && _config.ride) {
if (typeof config === 'string') {
if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
throw new TypeError(`No method named "${config}"`)
}
data[config]()
return
}
if (_config.interval && _config.ride) {
data.pause()
data.cycle()
}