aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorGeoSot <[email protected]>2021-06-10 02:35:59 +0300
committerXhmikosR <[email protected]>2021-07-29 16:30:02 +0300
commit8fc4f3aaf3598426c9077530949bac4fc3653f87 (patch)
tree278c150ca447fd13106b6842b68d7d41c0ab6a3e /js
parent1947ca033e0ad29ea65d069db7662632d5c66477 (diff)
downloadbootstrap-8fc4f3aaf3598426c9077530949bac4fc3653f87.tar.xz
bootstrap-8fc4f3aaf3598426c9077530949bac4fc3653f87.zip
initialize variable properly
Diffstat (limited to 'js')
-rw-r--r--js/src/collapse.js26
1 files changed, 10 insertions, 16 deletions
diff --git a/js/src/collapse.js b/js/src/collapse.js
index 3618c9ee3..58de34c1c 100644
--- a/js/src/collapse.js
+++ b/js/src/collapse.js
@@ -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()