Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/bootstrap.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorGeoSot <geo.sotis@gmail.com>2022-03-02 01:57:28 +0300
committerXhmikosR <xhmikosr@gmail.com>2022-03-09 18:25:47 +0300
commite77ae50311366b07225d15b19e330a3871123437 (patch)
treebef55c537ae3a161df144a71975fa093a9a68b07 /js
parent21fa2cfc122938ba34fcf94770fe2d6d2dfd7842 (diff)
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`.
Diffstat (limited to 'js')
-rw-r--r--js/src/carousel.js18
1 files changed, 11 insertions, 7 deletions
diff --git a/js/src/carousel.js b/js/src/carousel.js
index ea258527da..afe02f5b7b 100644
--- a/js/src/carousel.js
+++ b/js/src/carousel.js
@@ -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
+ }
+
+ if (typeof config === 'string') {
+ if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
+ throw new TypeError(`No method named "${config}"`)
}
- data[action]()
- } else if (_config.interval && _config.ride) {
+ data[config]()
+ return
+ }
+
+ if (_config.interval && _config.ride) {
data.pause()
data.cycle()
}