diff options
author | Felix Nagel <info@felixnagel.com> | 2016-10-24 22:24:09 +0200 |
---|---|---|
committer | Felix Nagel <info@felixnagel.com> | 2016-10-25 01:34:06 +0200 |
commit | f010087acae69dff67252236e4159c79124dd30b (patch) | |
tree | edbc634d0595c8d1f20d5f055f7df3f829685894 | |
parent | bd488f97a434ca54c0e57104ab85d2703444364b (diff) | |
download | jquery-ui-f010087acae69dff67252236e4159c79124dd30b.tar.gz jquery-ui-f010087acae69dff67252236e4159c79124dd30b.zip |
Calendar: Clear value if an invalid min / max option value was given
-rw-r--r-- | tests/unit/calendar/options.js | 10 | ||||
-rw-r--r-- | ui/widgets/calendar.js | 4 |
2 files changed, 12 insertions, 2 deletions
diff --git a/tests/unit/calendar/options.js b/tests/unit/calendar/options.js index c5bbdbf5a..ab352c4a0 100644 --- a/tests/unit/calendar/options.js +++ b/tests/unit/calendar/options.js @@ -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" ); diff --git a/ui/widgets/calendar.js b/ui/widgets/calendar.js index 006332d1b..7e40313e7 100644 --- a/ui/widgets/calendar.js +++ b/ui/widgets/calendar.js @@ -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; |