Skip to content

Commit

Permalink
Datepicker: Fixed current instance memory leak and added unit testcases
Browse files Browse the repository at this point in the history
  • Loading branch information
jigar140291 authored and fnagel committed Mar 23, 2020
1 parent 0c860b0 commit 817ce38
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
13 changes: 11 additions & 2 deletions tests/unit/datepicker/methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,18 @@ define( [
QUnit.module( "datepicker: methods" );

QUnit.test( "destroy", function( assert ) {
assert.expect( 33 );
assert.expect( 35 );
var inl,
inp = testHelper.init( "#inp" );
inp = testHelper.init( "#inp" ),
dp = $( "#ui-datepicker-div" );

// Destroy and clear active reference
inp.datepicker( "show" );
assert.equal( dp.css( "display" ), "block", "Datepicker - visible" );
inp.datepicker( "hide" ).datepicker( "destroy" );
assert.ok( $.datepicker._curInst == null, "Datepicker - destroyed and cleared reference" );

inp = testHelper.init( "#inp" );
assert.ok( inp.is( ".hasDatepicker" ), "Default - marker class set" );
assert.ok( $.data( inp[ 0 ], testHelper.PROP_NAME ), "Default - instance present" );
assert.ok( inp.next().is( "#alt" ), "Default - button absent" );
Expand Down
1 change: 1 addition & 0 deletions ui/widgets/datepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ $.extend( Datepicker.prototype, {

if ( datepicker_instActive === inst ) {
datepicker_instActive = null;
this._curInst = null;
}
},

Expand Down

0 comments on commit 817ce38

Please sign in to comment.