aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorMark Otto <[email protected]>2021-06-14 23:25:11 +0300
committerMark Otto <[email protected]>2021-07-05 17:22:29 -1000
commit359ed099e5b2f82bd602f2a6c45f43af8f2c87e8 (patch)
treeda343e462e97568af72c13d0d7571fa94e5cf083 /js
parent8bc89b273d078f57c2a11e9b9b0ff60daf7f8e21 (diff)
downloadbootstrap-359ed099e5b2f82bd602f2a6c45f43af8f2c87e8.tar.xz
bootstrap-359ed099e5b2f82bd602f2a6c45f43af8f2c87e8.zip
Add horizontal collapse support
Diffstat (limited to 'js')
-rw-r--r--js/src/collapse.js3
-rw-r--r--js/tests/unit/collapse.spec.js2
2 files changed, 3 insertions, 2 deletions
diff --git a/js/src/collapse.js b/js/src/collapse.js
index 8831510df..22bd31f9b 100644
--- a/js/src/collapse.js
+++ b/js/src/collapse.js
@@ -50,6 +50,7 @@ const CLASS_NAME_SHOW = 'show'
const CLASS_NAME_COLLAPSE = 'collapse'
const CLASS_NAME_COLLAPSING = 'collapsing'
const CLASS_NAME_COLLAPSED = 'collapsed'
+const CLASS_NAME_HORIZONTAL = 'collapse-horizontal'
const WIDTH = 'width'
const HEIGHT = 'height'
@@ -266,7 +267,7 @@ class Collapse extends BaseComponent {
}
_getDimension() {
- return this._element.classList.contains(WIDTH) ? WIDTH : HEIGHT
+ return this._element.classList.contains(CLASS_NAME_HORIZONTAL) ? WIDTH : HEIGHT
}
_getParent() {
diff --git a/js/tests/unit/collapse.spec.js b/js/tests/unit/collapse.spec.js
index 11d8d52bf..9bce3f0bb 100644
--- a/js/tests/unit/collapse.spec.js
+++ b/js/tests/unit/collapse.spec.js
@@ -225,7 +225,7 @@ describe('Collapse', () => {
})
it('should show a collapsed element on width', done => {
- fixtureEl.innerHTML = '<div class="collapse width" style="width: 0px;"></div>'
+ fixtureEl.innerHTML = '<div class="collapse collapse-horizontal" style="width: 0px;"></div>'
const collapseEl = fixtureEl.querySelector('div')
const collapse = new Collapse(collapseEl, {