aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorGeoSot <[email protected]>2022-02-19 19:04:50 +0200
committerXhmikosR <[email protected]>2022-03-01 16:56:33 +0200
commiteb8d5b43cedc76d88331f4d2f6ed3bca10e573ff (patch)
treef61c9a594b64fe54d1365ded497eb65bd4a211ba /js
parent13042d25cae2a8f5d43e24cd143cb1303aaed41e (diff)
downloadbootstrap-eb8d5b43cedc76d88331f4d2f6ed3bca10e573ff.tar.xz
bootstrap-eb8d5b43cedc76d88331f4d2f6ed3bca10e573ff.zip
Carousel: move `carouselInterface` inside `jqueryInterface`
Diffstat (limited to 'js')
-rw-r--r--js/src/carousel.js48
1 files changed, 22 insertions, 26 deletions
diff --git a/js/src/carousel.js b/js/src/carousel.js
index 12102f224..4262d60df 100644
--- a/js/src/carousel.js
+++ b/js/src/carousel.js
@@ -432,36 +432,32 @@ class Carousel extends BaseComponent {
}
// Static
- static carouselInterface(element, config) {
- const data = Carousel.getOrCreateInstance(element, config)
-
- let { _config } = data
- if (typeof config === 'object') {
- _config = {
- ..._config,
- ...config
+ static jQueryInterface(config) {
+ return this.each(function () {
+ const data = Carousel.getOrCreateInstance(this, config)
+
+ let { _config } = data
+ if (typeof config === 'object') {
+ _config = {
+ ..._config,
+ ...config
+ }
}
- }
- 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}"`)
- }
+ const action = typeof config === 'string' ? config : _config.slide
- data[action]()
- } else if (_config.interval && _config.ride) {
- data.pause()
- data.cycle()
- }
- }
+ if (typeof config === 'number') {
+ data.to(config)
+ } else if (typeof action === 'string') {
+ if (typeof data[action] === 'undefined') {
+ throw new TypeError(`No method named "${action}"`)
+ }
- static jQueryInterface(config) {
- return this.each(function () {
- Carousel.carouselInterface(this, config)
+ data[action]()
+ } else if (_config.interval && _config.ride) {
+ data.pause()
+ data.cycle()
+ }
})
}
}