Skip to content

Commit f010087

Browse files
committed
Calendar: Clear value if an invalid min / max option value was given
1 parent bd488f9 commit f010087

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

tests/unit/calendar/options.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ test( "showWeek", function() {
187187
} );
188188

189189
test( "min / max", function( assert ) {
190-
assert.expect( 17 );
190+
assert.expect( 19 );
191191

192192
// With existing date
193193
var prevButton = this.widget.find( ".ui-calendar-prev" ),
@@ -231,6 +231,14 @@ test( "min / max", function( assert ) {
231231
.calendar( "value", "1/4/09" );
232232
equal( this.element.calendar( "valueAsDate" ), null, "Min/max - value > max" );
233233

234+
this.element.calendar( "option", { min: minDate } );
235+
this.element.calendar( "option", { min: "invalid" } );
236+
equal( this.element.calendar( "option", "min" ), null, "Min/max - invalid" );
237+
238+
this.element.calendar( "option", { min: maxDate } );
239+
this.element.calendar( "option", { max: null } );
240+
equal( this.element.calendar( "option", "max" ), null, "Min/max - null" );
241+
234242
this.element
235243
.calendar( "option", { min: minDate, max: maxDate } )
236244
.calendar( "value", "3/4/08" );

ui/widgets/calendar.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,9 @@ return $.widget( "ui.calendar", {
723723
}
724724

725725
if ( key === "max" || key === "min" ) {
726-
if ( $.type( value ) === "date" || value === null ) {
726+
if ( $.type( value ) !== "date" || value === null ) {
727+
this._super( key, null );
728+
} else {
727729
this._super( key, value );
728730
}
729731
return;

0 commit comments

Comments
 (0)