]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Optimize jQueryInterface in Collapse (#35689)
authorAnton <info@ensostudio.ru>
Mon, 7 Feb 2022 08:50:26 +0000 (11:50 +0300)
committerGitHub <noreply@github.com>
Mon, 7 Feb 2022 08:50:26 +0000 (10:50 +0200)
extracts config initialization from cycle

js/src/collapse.js

index 8894342dfc29a7ac5b26b8ba28298a75fa10cfc0..b1088e106fb7e164a00b2a62de510aa49fdae67d 100644 (file)
@@ -256,12 +256,12 @@ class Collapse extends BaseComponent {
 
   // Static
   static jQueryInterface(config) {
-    return this.each(function () {
-      const _config = {}
-      if (typeof config === 'string' && /show|hide/.test(config)) {
-        _config.toggle = false
-      }
+    const _config = {}
+    if (typeof config === 'string' && /show|hide/.test(config)) {
+      _config.toggle = false
+    }
 
+    return this.each(function () {
       const data = Collapse.getOrCreateInstance(this, _config)
 
       if (typeof config === 'string') {