aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorMark Otto <[email protected]>2014-08-23 13:31:56 -0700
committerMark Otto <[email protected]>2014-08-23 13:31:56 -0700
commitf36e1c467c6d3080179de69a15641e9725ce636e (patch)
tree1d30f3580c1fa3e03473df92ddcc1add7242b2b7 /js
parent9a39ee90b4fd4d5b9b6f9a6f2c9d5a29ffeafe92 (diff)
parente3c26407827794df917f6d2d0f378cb5bf7f39e8 (diff)
downloadbootstrap-f36e1c467c6d3080179de69a15641e9725ce636e.tar.xz
bootstrap-f36e1c467c6d3080179de69a15641e9725ce636e.zip
Merge branch 'master' of github.com:twbs/bootstrap
Diffstat (limited to 'js')
-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()