File tree 2 files changed +24
-1
lines changed
2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ const ClassName = {
29
29
const Selector = {
30
30
DATA_TOGGLE_CARROT : '[data-toggle^="button"]' ,
31
31
DATA_TOGGLE : '[data-toggle="buttons"]' ,
32
- INPUT : 'input' ,
32
+ INPUT : 'input:not([type="hidden"]) ' ,
33
33
ACTIVE : '.active' ,
34
34
BUTTON : '.btn'
35
35
}
Original file line number Diff line number Diff line change @@ -139,6 +139,29 @@ $(function () {
139
139
assert . ok ( $btn2 . find ( 'input' ) . prop ( 'checked' ) , 'btn2 is checked' )
140
140
} )
141
141
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
+
142
165
QUnit . test ( 'should not add aria-pressed on labels for radio/checkbox inputs in a data-toggle="buttons" group' , function ( assert ) {
143
166
assert . expect ( 2 )
144
167
var groupHTML = '<div class="btn-group" data-toggle="buttons">' +
You can’t perform that action at this time.
0 commit comments