mirror of
https://github.com/twbs/bootstrap.git
synced 2024-11-28 10:24:19 +01:00
fix bootstrap-button toggle regression + tests
This commit is contained in:
parent
7ec09d0db9
commit
3d58b46226
Binary file not shown.
4
docs/assets/js/bootstrap-button.js
vendored
4
docs/assets/js/bootstrap-button.js
vendored
@ -91,7 +91,9 @@
|
||||
|
||||
$(function () {
|
||||
$('body').on('click.button.data-api', '[data-toggle^=button]', function ( e ) {
|
||||
$(e.currentTarget).button('toggle')
|
||||
var $btn = $(e.target)
|
||||
if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
|
||||
$btn.button('toggle')
|
||||
})
|
||||
})
|
||||
|
||||
|
4
js/bootstrap-button.js
vendored
4
js/bootstrap-button.js
vendored
@ -91,7 +91,9 @@
|
||||
|
||||
$(function () {
|
||||
$('body').on('click.button.data-api', '[data-toggle^=button]', function ( e ) {
|
||||
$(e.currentTarget).button('toggle')
|
||||
var $btn = $(e.target)
|
||||
if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
|
||||
$btn.button('toggle')
|
||||
})
|
||||
})
|
||||
|
||||
|
25
js/tests/unit/bootstrap-button.js
vendored
25
js/tests/unit/bootstrap-button.js
vendored
@ -45,10 +45,33 @@ $(function () {
|
||||
})
|
||||
|
||||
test("should toggle active", function () {
|
||||
var btn = $('<button class="btn" data-loading-text="fat">mdo</button>')
|
||||
var btn = $('<button class="btn">mdo</button>')
|
||||
ok(!btn.hasClass('active'), 'btn does not have active class')
|
||||
btn.button('toggle')
|
||||
ok(btn.hasClass('active'), 'btn has class active')
|
||||
})
|
||||
|
||||
test("should toggle active when btn children are clicked", function () {
|
||||
var btn = $('<button class="btn" data-toggle="button">mdo</button>')
|
||||
, inner = $('<i></i>')
|
||||
btn
|
||||
.append(inner)
|
||||
.appendTo($('#qunit-fixture'))
|
||||
ok(!btn.hasClass('active'), 'btn does not have active class')
|
||||
inner.click()
|
||||
ok(btn.hasClass('active'), 'btn has class active')
|
||||
})
|
||||
|
||||
test("should toggle active when btn children are clicked within btn-group", function () {
|
||||
var btngroup = $('<div class="btn-group" data-toggle="buttons-checkbox"></div>')
|
||||
, btn = $('<button class="btn">fat</button>')
|
||||
, inner = $('<i></i>')
|
||||
btngroup
|
||||
.append(btn.append(inner))
|
||||
.appendTo($('#qunit-fixture'))
|
||||
ok(!btn.hasClass('active'), 'btn does not have active class')
|
||||
inner.click()
|
||||
ok(btn.hasClass('active'), 'btn has class active')
|
||||
})
|
||||
|
||||
})
|
Loading…
Reference in New Issue
Block a user