File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed
Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ const ClassName = {
2929const Selector = {
3030 DATA_TOGGLE_CARROT : '[data-toggle^="button"]' ,
3131 DATA_TOGGLE : '[data-toggle="buttons"]' ,
32- INPUT : 'input' ,
32+ INPUT : 'input:not([type="hidden"]) ' ,
3333 ACTIVE : '.active' ,
3434 BUTTON : '.btn'
3535}
Original file line number Diff line number Diff line change @@ -139,6 +139,29 @@ $(function () {
139139 assert . ok ( $btn2 . find ( 'input' ) . prop ( 'checked' ) , 'btn2 is checked' )
140140 } )
141141
142+ QUnit . test ( 'should only toggle selectable inputs' , function ( assert ) {
143+ assert . expect ( 6 )
144+ var groupHTML = '<div class="btn-group" data-toggle="buttons">' +
145+ '<label class="btn btn-primary active">' +
146+ '<input type="hidden" name="option1" id="option1-default" value="false">' +
147+ '<input type="checkbox" name="option1" id="option1" checked="true"> Option 1' +
148+ '</label>' +
149+ '</div>'
150+ var $group = $ ( groupHTML ) . appendTo ( '#qunit-fixture' )
151+
152+ var $btn = $group . children ( ) . eq ( 0 )
153+ var $hidden = $btn . find ( 'input#option1-default' )
154+ var $cb = $btn . find ( 'input#option1' )
155+
156+ assert . ok ( $btn . hasClass ( 'active' ) , 'btn has active class' )
157+ assert . ok ( $cb . prop ( 'checked' ) , 'btn is checked' )
158+ assert . ok ( ! $hidden . prop ( 'checked' ) , 'hidden is not checked' )
159+ $btn . trigger ( 'click' )
160+ assert . ok ( ! $btn . hasClass ( 'active' ) , 'btn does not have active class' )
161+ assert . ok ( ! $cb . prop ( 'checked' ) , 'btn is not checked' )
162+ assert . ok ( ! $hidden . prop ( 'checked' ) , 'hidden is not checked' ) // should not be changed
163+ } )
164+
142165 QUnit . test ( 'should not add aria-pressed on labels for radio/checkbox inputs in a data-toggle="buttons" group' , function ( assert ) {
143166 assert . expect ( 2 )
144167 var groupHTML = '<div class="btn-group" data-toggle="buttons">' +
You can’t perform that action at this time.
0 commit comments