Skip to content

Commit

Permalink
Dialog: Restore inline styles for dimensions/display. Fixes #8119 - D…
Browse files Browse the repository at this point in the history
…ialog: Destroying a dialog leaves some styles changed.
  • Loading branch information
scottgonzalez committed Dec 5, 2012
1 parent 70f5d18 commit f59f5a8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
15 changes: 11 additions & 4 deletions tests/unit/dialog/dialog_methods.js
Expand Up @@ -34,12 +34,9 @@ test("init", function() {
}); });


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


// Dialogs are expected to be hidden on destroy, so make sure they're hidden
// before the test
$( "#dialog1, #form-dialog" ).hide(); $( "#dialog1, #form-dialog" ).hide();

domEqual( "#dialog1", function() { domEqual( "#dialog1", function() {
var dialog = $( "#dialog1" ).dialog().dialog( "destroy" ); var dialog = $( "#dialog1" ).dialog().dialog( "destroy" );
equal( dialog.parent()[ 0 ], $( "#qunit-fixture" )[ 0 ] ); equal( dialog.parent()[ 0 ], $( "#qunit-fixture" )[ 0 ] );
Expand All @@ -50,6 +47,16 @@ test("destroy", function() {
equal( dialog.parent()[ 0 ], $( "#qunit-fixture" )[ 0 ] ); equal( dialog.parent()[ 0 ], $( "#qunit-fixture" )[ 0 ] );
equal( dialog.index(), 2 ); equal( dialog.index(), 2 );
}); });

// Ensure dimensions are restored (#8119)
$( "#dialog1" ).show().css({
width: "400px",
minHeight: "100px",
height: "200px"
});
domEqual( "#dialog1", function() {
$( "#dialog1" ).dialog().dialog( "destroy" );
});
}); });


test( "enable/disable disabled", function() { test( "enable/disable disabled", function() {
Expand Down
13 changes: 7 additions & 6 deletions ui/jquery.ui.dialog.js
Expand Up @@ -84,6 +84,12 @@ $.widget("ui.dialog", {
}, },


_create: function() { _create: function() {
this.originalCss = {
display: this.element[0].style.display,
width: this.element[0].style.width,
minHeight: this.element[0].style.minHeight,
height: this.element[0].style.height
};
this.originalTitle = this.element.attr( "title" ); this.originalTitle = this.element.attr( "title" );
this.options.title = this.options.title || this.originalTitle; this.options.title = this.options.title || this.originalTitle;
this.oldPosition = { this.oldPosition = {
Expand Down Expand Up @@ -127,12 +133,7 @@ $.widget("ui.dialog", {
this.element this.element
.removeUniqueId() .removeUniqueId()
.removeClass( "ui-dialog-content ui-widget-content" ) .removeClass( "ui-dialog-content ui-widget-content" )
.css({ .css( this.originalCss )
width: "",
minHeight: "",
height: ""
})
.hide()
// without detaching first, the following becomes really slow // without detaching first, the following becomes really slow
.detach(); .detach();


Expand Down

1 comment on commit f59f5a8

@domenic
Copy link

@domenic domenic commented on f59f5a8 Dec 5, 2012

Choose a reason for hiding this comment

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

Looks lovely! Thank you :)

Please sign in to comment.