]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
initialize variable properly
authorGeoSot <geo.sotis@gmail.com>
Wed, 9 Jun 2021 23:35:59 +0000 (02:35 +0300)
committerXhmikosR <xhmikosr@gmail.com>
Thu, 29 Jul 2021 13:30:02 +0000 (16:30 +0300)
js/src/collapse.js

index 3618c9ee392abb6298e77f9e021048ae0162f48a..58de34c1cf3eb570d2254989974c14900fce3e85 100644 (file)
@@ -125,7 +125,7 @@ class Collapse extends BaseComponent {
       return
     }
 
-    let actives
+    let actives = []
     let activesData
 
     if (this._parent) {
@@ -137,14 +137,10 @@ class Collapse extends BaseComponent {
 
           return elem.classList.contains(CLASS_NAME_COLLAPSE)
         })
-
-      if (actives.length === 0) {
-        actives = null
-      }
     }
 
     const container = SelectorEngine.findOne(this._selector)
-    if (actives) {
+    if (actives.length) {
       const tempActiveData = actives.find(elem => container !== elem)
       activesData = tempActiveData ? Collapse.getInstance(tempActiveData) : null
 
@@ -158,17 +154,15 @@ class Collapse extends BaseComponent {
       return
     }
 
-    if (actives) {
-      actives.forEach(elemActive => {
-        if (container !== elemActive) {
-          Collapse.collapseInterface(elemActive, 'hide')
-        }
+    actives.forEach(elemActive => {
+      if (container !== elemActive) {
+        Collapse.collapseInterface(elemActive, 'hide')
+      }
 
-        if (!activesData) {
-          Data.set(elemActive, DATA_KEY, null)
-        }
-      })
-    }
+      if (!activesData) {
+        Data.set(elemActive, DATA_KEY, null)
+      }
+    })
 
     const dimension = this._getDimension()