0
0
mirror of https://github.com/twbs/bootstrap.git synced 2024-12-01 13:24:25 +01:00

Merge pull request #18847 from Johann-S/fix18824

Fix bug multiple accordions collapse
This commit is contained in:
Mark Otto 2016-10-24 20:50:04 -07:00 committed by GitHub
commit 60e51bc918
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')