Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Datepicker: hides on destroy
Co-authored-by: DawnSovereign <jason.t.kim2@gmail.com>
  • Loading branch information
porterclev and JasonKimy committed Jul 22, 2024
commit 340941831cdb91d3f7f859c4fd45fce8a75c3605
11 changes: 10 additions & 1 deletion tests/unit/datepicker/methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var beforeAfterEach = testHelper.beforeAfterEach;
QUnit.module( "datepicker: methods", beforeAfterEach() );

QUnit.test( "destroy", function( assert ) {
assert.expect( 35 );
assert.expect( 39 );
var inl,
inp = testHelper.init( "#inp" ),
dp = $( "#ui-datepicker-div" );
Expand All @@ -21,6 +21,15 @@ QUnit.test( "destroy", function( assert ) {
assert.equal( dp.css( "display" ), "block", "Datepicker - visible" );
inp.datepicker( "hide" ).datepicker( "destroy" );
assert.ok( $.datepicker._curInst == null, "Datepicker - destroyed and cleared reference" );
assert.equal( dp.css( "display" ), "none", "Datepicker - absent" );

// Destroy Without Hiding
Comment thread
fnagel marked this conversation as resolved.
Outdated
inp = testHelper.init( "#inp" );
inp.datepicker( "show" );
assert.equal( dp.css( "display" ), "block", "Datepicker - visible" );
inp.datepicker( "destroy" );
assert.ok( $.datepicker._curInst == null, "Datepicker - destroyed and cleared reference" );
assert.equal( dp.css( "display" ), "none", "Datepicker - absent" );

inp = testHelper.init( "#inp" );
assert.ok( inp.is( ".hasDatepicker" ), "Default - marker class set" );
Expand Down
4 changes: 1 addition & 3 deletions ui/widgets/datepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -434,12 +434,10 @@ $.extend( Datepicker.prototype, {
} else if ( nodeName === "div" || nodeName === "span" ) {
$target.removeClass( this.markerClassName ).empty();
}

inst.dpDiv.remove();
$.datepicker._hideDatepicker();
if ( datepicker_instActive === inst ) {
datepicker_instActive = null;
this._curInst = null;
this.dpDiv = null;
}
},

Expand Down