0
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-03-01 01:54: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') { if (typeof config === 'number') {
data.to(config) data.to(config)
} else if (typeof action === 'string') { return
if (typeof data[action] === 'undefined') { }
throw new TypeError(`No method named "${action}"`)
if (typeof config === 'string') {
if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
throw new TypeError(`No method named "${config}"`)
} }
data[action]() data[config]()
} else if (_config.interval && _config.ride) { return
}
if (_config.interval && _config.ride) {
data.pause() data.pause()
data.cycle() data.cycle()
} }