Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
9 changes: 8 additions & 1 deletion tests/unit/dialog/dialog_methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ test("init", function() {
});

test("destroy", function() {
expect( 7 );
expect( 9 );

$( "#dialog1, #form-dialog" ).hide();
domEqual( "#dialog1", function() {
Expand All @@ -57,6 +57,13 @@ test("destroy", function() {
domEqual( "#dialog1", function() {
$( "#dialog1" ).dialog().dialog( "destroy" );
});

// Don't throw errors when destroying a never opened modal dialog (#9004)
$( "#dialog1" ).dialog({ autoOpen: false, modal: true }).dialog( "destroy" );
ok(true, "destory never opened modal dialog");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

destory -> destroy


$( "#dialog1" ).dialog({ modal: true }).dialog( "destroy" );
equal( $( ".ui-widget-overlay" ).length, 0, "overlay removed when dialog is destroyed" );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When verifying that the overlay is removed, you should first verify that the overlay exists while the dialog is open.

});

test("#4980: Destroy should place element back in original DOM position", function(){
Expand Down
4 changes: 3 additions & 1 deletion ui/jquery.ui.dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,9 @@ $.widget( "ui.dialog", {
if ( !$.ui.dialog.overlayInstances ) {
this._off( this.document, "focusin" );
}
this.overlay.remove();
if ( this.overlay ) {
this.overlay.remove();
}
}
});

Expand Down