collapse.js: return early.

This commit is contained in:
XhmikosR 2020-06-10 18:42:21 +03:00
parent 8debdf6ce6
commit 12b754800c
1 changed files with 14 additions and 14 deletions

View File

@ -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