Skip to content

Commit

Permalink
Reverse twbs#22138 and detache accordion from card without requiring …
Browse files Browse the repository at this point in the history
…'data-children'
  • Loading branch information
pvdlg committed Mar 23, 2017
1 parent 4f37ad2 commit ed6fd20
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
4 changes: 2 additions & 2 deletions js/src/collapse.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const Collapse = (($) => {
}

const Selector = {
ACTIVES : '.card > .show, .card > .collapsing',
ACTIVES : '.show, .collapsing',
DATA_TOGGLE : '[data-toggle="collapse"]'
}

Expand Down Expand Up @@ -124,7 +124,7 @@ const Collapse = (($) => {
let activesData

if (this._parent) {
actives = $.makeArray($(this._parent).find(Selector.ACTIVES))
actives = $.makeArray($(this._parent).children().children(Selector.ACTIVES))
if (!actives.length) {
actives = null
}
Expand Down
24 changes: 24 additions & 0 deletions js/tests/unit/collapse.js
Original file line number Diff line number Diff line change
Expand Up @@ -490,4 +490,28 @@ $(function () {
.bootstrapCollapse('show')
})

QUnit.test('should allow accordion to use children other than card', function (assert) {
assert.expect(2)
var done = assert.async()
var accordionHTML = '<div id="accordion">'
+ '<div class="item">'
+ '<a id="linkTrigger" data-parent="#accordion" data-toggle="collapse" href="#collapseOne" aria-expanded="false" aria-controls="collapseOne"></a>'
+ '<div id="collapseOne" class="collapse" role="tabpanel" aria-labelledby="headingThree"></div>'
+ '</div>'
+ '<div class="item">'
+ '<a data-toggle="collapse" data-parent="#accordion" href="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo"></a>'
+ '<div id="collapseTwo" class="collapse show" role="tabpanel" aria-labelledby="headingTwo"></div>'
+ '</div>'
+ '</div>'

$(accordionHTML).appendTo('#qunit-fixture')
var $target = $('#linkTrigger')
$('#collapseOne').on('shown.bs.collapse', function () {
assert.ok($(this).hasClass('show'))
assert.ok(!$('#collapseTwo').hasClass('show'))
done()
})
$target.trigger($.Event('click'))
})

})

0 comments on commit ed6fd20

Please sign in to comment.