aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfat <[email protected]>2014-08-18 19:58:19 -0700
committerfat <[email protected]>2014-08-18 19:58:19 -0700
commit9c2e54bfeca744ca3d2ab811b23d9a083502c53d (patch)
tree604adc351b5ad1605f4cfead4e66c81e3c09ebf2
parentea0e1606dc8f6a351c850a3e51889872c0f07c31 (diff)
downloadbootstrap-9c2e54bfeca744ca3d2ab811b23d9a083502c53d.tar.xz
bootstrap-9c2e54bfeca744ca3d2ab811b23d9a083502c53d.zip
fixes #14282 - Already Visible collapse gets closed when .collapse('show') is called
-rw-r--r--js/collapse.js2
-rw-r--r--js/tests/unit/collapse.js32
2 files changed, 33 insertions, 1 deletions
diff --git a/js/collapse.js b/js/collapse.js
index a265344f4..db89804cb 100644
--- a/js/collapse.js
+++ b/js/collapse.js
@@ -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]()
})
diff --git a/js/tests/unit/collapse.js b/js/tests/unit/collapse.js
index 8e6bb8273..ffa8f7e6d 100644
--- a/js/tests/unit/collapse.js
+++ b/js/tests/unit/collapse.js
@@ -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()