0
0
mirror of https://github.com/twbs/bootstrap.git synced 2024-11-29 11:24:18 +01:00

Fix bug multiple accordions collapse

This commit is contained in:
Johann-S 2016-01-11 20:42:35 +01:00
parent 16947ffa88
commit 9bc7de9395
2 changed files with 24 additions and 1 deletions

View File

@ -121,7 +121,7 @@ const Collapse = (($) => {
let activesData
if (this._parent) {
actives = $.makeArray($(Selector.ACTIVES))
actives = $.makeArray($(this._parent).find(Selector.ACTIVES))
if (!actives.length) {
actives = null
}

View File

@ -52,6 +52,29 @@ $(function () {
assert.ok(!/height/i.test($el.attr('style')), 'has height reset')
})
QUnit.test('should collapse only the first collapse', function (assert) {
assert.expect(2)
var html = [
'<div class="panel-group" id="accordion1">',
'<div class="panel">',
'<div id="collapse1" class="collapse"/>',
'</div>',
'</div>',
'<div class="panel-group" id="accordion2">',
'<div class="panel">',
'<div id="collapse2" class="collapse in"/>',
'</div>',
'</div>'
].join('')
$(html).appendTo('#qunit-fixture')
var $el1 = $('#collapse1')
var $el2 = $('#collapse2')
$el1.bootstrapCollapse('show')
assert.ok($el1.hasClass('in'))
assert.ok($el2.hasClass('in'))
})
QUnit.test('should hide a collapsed element', function (assert) {
assert.expect(1)
var $el = $('<div class="collapse"/>').bootstrapCollapse('hide')