From 12b754800c5bc56bd0b757e335d70cee439400b7 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Wed, 10 Jun 2020 18:42:21 +0300 Subject: [PATCH] collapse.js: return early. --- js/src/collapse.js | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/js/src/collapse.js b/js/src/collapse.js index be65529556..693e7ee2c8 100644 --- a/js/src/collapse.js +++ b/js/src/collapse.js @@ -318,21 +318,21 @@ class Collapse { } _addAriaAndCollapsedClass(element, triggerArray) { - if (element) { - const isOpen = element.classList.contains(CLASS_NAME_SHOW) - - if (triggerArray.length) { - triggerArray.forEach(elem => { - if (isOpen) { - elem.classList.remove(CLASS_NAME_COLLAPSED) - } else { - elem.classList.add(CLASS_NAME_COLLAPSED) - } - - elem.setAttribute('aria-expanded', isOpen) - }) - } + if (!element || !triggerArray.length) { + return } + + const isOpen = element.classList.contains(CLASS_NAME_SHOW) + + triggerArray.forEach(elem => { + if (isOpen) { + elem.classList.remove(CLASS_NAME_COLLAPSED) + } else { + elem.classList.add(CLASS_NAME_COLLAPSED) + } + + elem.setAttribute('aria-expanded', isOpen) + }) } // Static