From ed6fd20bff7a1982fc852066a56c2934117cbcc3 Mon Sep 17 00:00:00 2001 From: Pierre-Denis Vanduynslager Date: Thu, 23 Mar 2017 11:26:18 -0400 Subject: [PATCH] Reverse #22138 and detache accordion from card without requiring 'data-children' --- js/src/collapse.js | 4 ++-- js/tests/unit/collapse.js | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/js/src/collapse.js b/js/src/collapse.js index ed3c064b1665..365365152046 100644 --- a/js/src/collapse.js +++ b/js/src/collapse.js @@ -56,7 +56,7 @@ const Collapse = (($) => { } const Selector = { - ACTIVES : '.card > .show, .card > .collapsing', + ACTIVES : '.show, .collapsing', DATA_TOGGLE : '[data-toggle="collapse"]' } @@ -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 } diff --git a/js/tests/unit/collapse.js b/js/tests/unit/collapse.js index 7139304338a0..e937924d8c58 100644 --- a/js/tests/unit/collapse.js +++ b/js/tests/unit/collapse.js @@ -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 = '
' + + '
' + + '' + + '
' + + '
' + + '
' + + '' + + '
' + + '
' + + '
' + + $(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')) + }) + })