File tree Expand file tree Collapse file tree 2 files changed +9
-18
lines changed
Expand file tree Collapse file tree 2 files changed +9
-18
lines changed Original file line number Diff line number Diff line change 5757 var $input = this . $element . find ( 'input' )
5858 if ( $input . prop ( 'type' ) == 'radio' ) {
5959 if ( $input . prop ( 'checked' ) ) changed = false
60- if ( ! $input . prop ( 'checked' ) || ! this . $element . hasClass ( 'active' ) ) $parent . find ( '.active' ) . removeClass ( 'active' )
60+ $parent . find ( '.active' ) . removeClass ( 'active' )
61+ this . $element . addClass ( 'active' )
62+ } else if ( $input . prop ( 'type' ) == 'checkbox' ) {
63+ if ( ( $input . prop ( 'checked' ) ) !== this . $element . hasClass ( 'active' ) ) changed = false
64+ this . $element . toggleClass ( 'active' )
6165 }
62- if ( changed ) $input . prop ( 'checked' , ! this . $element . hasClass ( 'active' ) ) . trigger ( 'change' )
66+ $input . prop ( 'checked' , this . $element . hasClass ( 'active' ) )
67+ if ( changed ) $input . trigger ( 'change' )
6368 } else {
6469 this . $element . attr ( 'aria-pressed' , ! this . $element . hasClass ( 'active' ) )
70+ this . $element . toggleClass ( 'active' )
6571 }
66-
67- if ( changed ) this . $element . toggleClass ( 'active' )
6872 }
6973
7074
107111 var $btn = $ ( e . target )
108112 if ( ! $btn . hasClass ( 'btn' ) ) $btn = $btn . closest ( '.btn' )
109113 Plugin . call ( $btn , 'toggle' )
110- if ( ! $ ( e . target ) . is ( 'input[type="radio"]' ) ) e . preventDefault ( )
114+ if ( ! ( $ ( e . target ) . is ( 'input[type="radio"]' ) || $ ( e . target ) . is ( 'input[type="checkbox"]' ) ) ) e . preventDefault ( )
111115 } )
112116 . on ( 'focus.bs.button.data-api blur.bs.button.data-api' , '[data-toggle^="button"]' , function ( e ) {
113117 $ ( e . target ) . closest ( '.btn' ) . toggleClass ( 'focus' , / ^ f o c u s ( i n ) ? $ / . test ( e . type ) )
Original file line number Diff line number Diff line change @@ -130,19 +130,6 @@ $(function () {
130130 assert . strictEqual ( $btn . attr ( 'aria-pressed' ) , 'true' , 'btn aria-pressed state is true' )
131131 } )
132132
133- QUnit . test ( 'should toggle active when btn children are clicked within btn-group' , function ( assert ) {
134- assert . expect ( 2 )
135- var $btngroup = $ ( '<div class="btn-group" data-toggle="buttons"/>' )
136- var $btn = $ ( '<button class="btn">fat</button>' )
137- var $inner = $ ( '<i/>' )
138- $btngroup
139- . append ( $btn . append ( $inner ) )
140- . appendTo ( '#qunit-fixture' )
141- assert . ok ( ! $btn . hasClass ( 'active' ) , 'btn does not have active class' )
142- $inner . trigger ( 'click' )
143- assert . ok ( $btn . hasClass ( 'active' ) , 'btn has class active' )
144- } )
145-
146133 QUnit . test ( 'should check for closest matching toggle' , function ( assert ) {
147134 assert . expect ( 12 )
148135 var groupHTML = '<div class="btn-group" data-toggle="buttons">'
You can’t perform that action at this time.
0 commit comments