From 8fc4f3aaf3598426c9077530949bac4fc3653f87 Mon Sep 17 00:00:00 2001 From: GeoSot Date: Thu, 10 Jun 2021 02:35:59 +0300 Subject: [PATCH] initialize variable properly --- js/src/collapse.js | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/js/src/collapse.js b/js/src/collapse.js index 3618c9ee39..58de34c1cf 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()