]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Simplify check for children
authorGeoSot <geo.sotis@gmail.com>
Wed, 9 Jun 2021 23:36:35 +0000 (02:36 +0300)
committerXhmikosR <xhmikosr@gmail.com>
Thu, 29 Jul 2021 13:30:02 +0000 (16:30 +0300)
js/src/collapse.js

index 58de34c1cf3eb570d2254989974c14900fce3e85..21ee5cceecd1ebf05a3db439757afb788e847ac2 100644 (file)
@@ -129,14 +129,8 @@ class Collapse extends BaseComponent {
     let activesData
 
     if (this._parent) {
-      actives = SelectorEngine.find(SELECTOR_ACTIVES, this._parent)
-        .filter(elem => {
-          if (typeof this._config.parent === 'string') {
-            return elem.getAttribute('data-bs-parent') === this._config.parent
-          }
-
-          return elem.classList.contains(CLASS_NAME_COLLAPSE)
-        })
+      const children = SelectorEngine.find(`.${CLASS_NAME_COLLAPSE} .${CLASS_NAME_COLLAPSE}`, this._parent)
+      actives = SelectorEngine.find(SELECTOR_ACTIVES, this._parent).filter(elem => !children.includes(elem)) // remove children if greater depth
     }
 
     const container = SelectorEngine.findOne(this._selector)