]> source.dussan.org Git - jquery-ui.git/commitdiff
Calendar: Clear value if an invalid min / max option value was given
authorFelix Nagel <info@felixnagel.com>
Mon, 24 Oct 2016 20:24:09 +0000 (22:24 +0200)
committerFelix Nagel <info@felixnagel.com>
Mon, 24 Oct 2016 23:34:06 +0000 (01:34 +0200)
tests/unit/calendar/options.js
ui/widgets/calendar.js

index c5bbdbf5ab7fccfbb5f7d6652f516c576a70b61e..ab352c4a038b604057926116d1c34f1ce57d3749 100644 (file)
@@ -187,7 +187,7 @@ test( "showWeek", function() {
 } );
 
 test( "min / max", function( assert ) {
-       assert.expect( 17 );
+       assert.expect( 19 );
 
        // With existing date
        var prevButton = this.widget.find( ".ui-calendar-prev" ),
@@ -231,6 +231,14 @@ test( "min / max", function( assert ) {
                .calendar( "value", "1/4/09" );
        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
                .calendar( "option", { min: minDate, max: maxDate } )
                .calendar( "value", "3/4/08" );
index 006332d1bd77d937d9139ab16c2d824fda9879e5..7e40313e72420a507056aa4fa5c06a333c8f509c 100644 (file)
@@ -723,7 +723,9 @@ return $.widget( "ui.calendar", {
                }
 
                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 );
                        }
                        return;