Skip to content

Commit

Permalink
Merge pull request #14417 from twbs/fat-14282
Browse files Browse the repository at this point in the history
fixes #14282 - Already Visible collapse gets closed when …
  • Loading branch information
mdo committed Aug 23, 2014
2 parents f265137 + 9c2e54b commit 875006d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion js/collapse.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
var data = $this.data('bs.collapse')
var options = $.extend({}, Collapse.DEFAULTS, $this.data(), typeof option == 'object' && option)

if (!data && options.toggle && option == 'show') option = !option
if (!data && options.toggle && option == 'show') options.toggle = false
if (!data) $this.data('bs.collapse', (data = new Collapse(this, options)))
if (typeof option == 'string') data[option]()
})
Expand Down
32 changes: 32 additions & 0 deletions js/tests/unit/collapse.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,38 @@ $(function () {
$target.click()
})

test('should not close a collapse when initialized with "show" if already shown', function () {
stop()

expect(0)

var $test = $('<div id="test1" class="in"/>')
.appendTo('#qunit-fixture')
.on('hide.bs.collapse', function () {
ok(false)
})

$test.bootstrapCollapse('show')

setTimeout(start, 0)
})

test('should open a collapse when initialized with "show" if not already shown', function () {
stop()

expect(1)

var $test = $('<div id="test1" />')
.appendTo('#qunit-fixture')
.on('show.bs.collapse', function () {
ok(true)
})

$test.bootstrapCollapse('show')

setTimeout(start, 0)
})

test('should remove "collapsed" class from active accordion target', function () {
stop()

Expand Down

0 comments on commit 875006d

Please sign in to comment.