File tree Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -1439,7 +1439,9 @@ $.extend(Selectize.prototype, {
14391439 var self = this ;
14401440 var invalid = self . isRequired && ! self . items . length ;
14411441 if ( ! invalid ) self . isInvalid = false ;
1442- self . $control_input . prop ( 'required' , invalid ) ;
1442+ if ( self . isRequired ) {
1443+ self . $control_input . prop ( 'required' , invalid ) ;
1444+ } ;
14431445 self . refreshClasses ( ) ;
14441446 } ,
14451447
Original file line number Diff line number Diff line change 218218 }
219219 } ) ;
220220
221+ describe ( '<select> (not required)' , function ( ) {
222+ var $form , $button , test ;
223+
224+ beforeEach ( function ( ) {
225+ test = setup_test ( '<select>' +
226+ '<option value="">Select an option...</option>' +
227+ '<option value="a">A</option>' +
228+ '</select>' , { } ) ;
229+ $form = test . $select . parents ( 'form' ) ;
230+ $button = $ ( '<button type="submit">' ) . appendTo ( $form ) ;
231+ } ) ;
232+ afterEach ( function ( ) {
233+ $form . off ( '.test_required' ) ;
234+ $button . remove ( ) ;
235+ } ) ;
236+
237+ it ( 'should have isRequired property set to false' , function ( ) {
238+ expect ( test . selectize . isRequired ) . to . be . equal ( false ) ;
239+ } ) ;
240+ it ( 'should not have the required class' , function ( ) {
241+ expect ( test . selectize . $control . hasClass ( 'required' ) ) . to . be . equal ( false ) ;
242+ } ) ;
243+ } ) ;
244+
221245 } ) ;
222246
223- } ) ( ) ;
247+ } ) ( ) ;
You can’t perform that action at this time.
0 commit comments