Skip to content

Commit

Permalink
collapse.js: return early.
Browse files Browse the repository at this point in the history
  • Loading branch information
XhmikosR committed Jun 11, 2020
1 parent bf0dd93 commit f851164
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions js/src/collapse.js
Expand Up @@ -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)
}
if (!element || !triggerArray.length) {
return
}

elem.setAttribute('aria-expanded', isOpen)
})
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
Expand Down

0 comments on commit f851164

Please sign in to comment.