From de20614bd7332b740c6ec095e0e5c48c2f97c8bf Mon Sep 17 00:00:00 2001 From: Felix Nagel Date: Sun, 11 Dec 2016 23:10:26 +0100 Subject: [PATCH] Calendar: Make select and change event pass the current value --- tests/unit/calendar/events.js | 10 ++++++---- ui/widgets/calendar.js | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/unit/calendar/events.js b/tests/unit/calendar/events.js index 59508cb8a..6dc2e5eef 100644 --- a/tests/unit/calendar/events.js +++ b/tests/unit/calendar/events.js @@ -12,12 +12,12 @@ QUnit.module( "calendar: events", { } ); QUnit.test( "change", function( assert ) { - assert.expect( 6 ); + assert.expect( 8 ); var shouldFire, eventType; this.element.calendar( { - change: function( event ) { + change: function( event, ui ) { assert.ok( shouldFire, "change event fired" ); assert.equal( event.type, @@ -29,6 +29,7 @@ QUnit.test( "change", function( assert ) { eventType, "change originalEvent on calendar button " + eventType ); + assert.equal( $.type( ui.value ), "date", "value is a date object" ); } } ); @@ -48,14 +49,14 @@ QUnit.test( "change", function( assert ) { } ); QUnit.test( "select", function( assert ) { - assert.expect( 6 ); + assert.expect( 8 ); var ready = assert.async(), that = this, message, eventType; this.element.calendar( { - select: function( event ) { + select: function( event, ui ) { assert.ok( true, "select event fired " + message ); assert.equal( event.type, @@ -67,6 +68,7 @@ QUnit.test( "select", function( assert ) { eventType, "select originalEvent " + message ); + assert.equal( $.type( ui.value ), "date", "value is a date object" ); } } ); diff --git a/ui/widgets/calendar.js b/ui/widgets/calendar.js index 538230bb6..0c961a3d7 100644 --- a/ui/widgets/calendar.js +++ b/ui/widgets/calendar.js @@ -134,13 +134,13 @@ return $.widget( "ui.calendar", { this._updateDayElement( "ui-state-active" ); // Allow datepicker to handle focus - if ( this._trigger( "select", event ) !== false ) { + if ( this._trigger( "select", event, { value: this.options.value } ) !== false ) { this.activeDescendant.closest( this.grid ).focus(); event.preventDefault(); } if ( oldValue !== this.options.value.getTime() ) { - this._trigger( "change", event ); + this._trigger( "change", event, { value: this.options.value } ); } }, -- 2.39.5