Calendar: Clear value if an invalid min / max option value was given

This commit is contained in:
Felix Nagel 2016-10-24 22:24:09 +02:00
parent bd488f97a4
commit f010087aca
2 changed files with 12 additions and 2 deletions

View File

@ -187,7 +187,7 @@ test( "showWeek", function() {
} ); } );
test( "min / max", function( assert ) { test( "min / max", function( assert ) {
assert.expect( 17 ); assert.expect( 19 );
// With existing date // With existing date
var prevButton = this.widget.find( ".ui-calendar-prev" ), var prevButton = this.widget.find( ".ui-calendar-prev" ),
@ -231,6 +231,14 @@ test( "min / max", function( assert ) {
.calendar( "value", "1/4/09" ); .calendar( "value", "1/4/09" );
equal( this.element.calendar( "valueAsDate" ), null, "Min/max - value > max" ); equal( this.element.calendar( "valueAsDate" ), null, "Min/max - value > max" );
this.element.calendar( "option", { min: minDate } );
this.element.calendar( "option", { min: "invalid" } );
equal( this.element.calendar( "option", "min" ), null, "Min/max - invalid" );
this.element.calendar( "option", { min: maxDate } );
this.element.calendar( "option", { max: null } );
equal( this.element.calendar( "option", "max" ), null, "Min/max - null" );
this.element this.element
.calendar( "option", { min: minDate, max: maxDate } ) .calendar( "option", { min: minDate, max: maxDate } )
.calendar( "value", "3/4/08" ); .calendar( "value", "3/4/08" );

View File

@ -723,7 +723,9 @@ return $.widget( "ui.calendar", {
} }
if ( key === "max" || key === "min" ) { if ( key === "max" || key === "min" ) {
if ( $.type( value ) === "date" || value === null ) { if ( $.type( value ) !== "date" || value === null ) {
this._super( key, null );
} else {
this._super( key, value ); this._super( key, value );
} }
return; return;