mirror of
https://github.com/twbs/bootstrap.git
synced 2024-11-29 11:24:18 +01:00
Merge pull request #18847 from Johann-S/fix18824
Fix bug multiple accordions collapse
This commit is contained in:
commit
60e51bc918
@ -121,7 +121,7 @@ const Collapse = (($) => {
|
|||||||
let activesData
|
let activesData
|
||||||
|
|
||||||
if (this._parent) {
|
if (this._parent) {
|
||||||
actives = $.makeArray($(Selector.ACTIVES))
|
actives = $.makeArray($(this._parent).find(Selector.ACTIVES))
|
||||||
if (!actives.length) {
|
if (!actives.length) {
|
||||||
actives = null
|
actives = null
|
||||||
}
|
}
|
||||||
|
@ -52,6 +52,29 @@ $(function () {
|
|||||||
assert.ok(!/height/i.test($el.attr('style')), 'has height reset')
|
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) {
|
QUnit.test('should hide a collapsed element', function (assert) {
|
||||||
assert.expect(1)
|
assert.expect(1)
|
||||||
var $el = $('<div class="collapse"/>').bootstrapCollapse('hide')
|
var $el = $('<div class="collapse"/>').bootstrapCollapse('hide')
|
||||||
|
Loading…
Reference in New Issue
Block a user