]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Carousel: move `carouselInterface` inside `jqueryInterface`
authorGeoSot <geo.sotis@gmail.com>
Sat, 19 Feb 2022 17:04:50 +0000 (19:04 +0200)
committerXhmikosR <xhmikosr@gmail.com>
Tue, 1 Mar 2022 14:56:33 +0000 (16:56 +0200)
js/src/carousel.js

index 12102f2246ee8feda8247785d098a6239cc5f7c8..4262d60dfda952920bb3728ada78b2a46831b23c 100644 (file)
@@ -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()
+      }
     })
   }
 }