8000 Dialog: Restore inline styles for dimensions/display. Fixes #8119 - D… · faroncoder/jquery-ui@f59f5a8 · GitHub
[go: up one dir, main page]

Skip to content

Commit f59f5a8

Browse files
committed
Dialog: Restore inline styles for dimensions/display. Fixes #8119 - Dialog: Destroying a dialog leaves some styles changed.
1 parent 70f5d18 commit f59f5a8

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

tests/unit/dialog/dialog_methods.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,9 @@ test("init", function() {
3434
});
3535

3636
test("destroy", function() {
37-
expect( 6 );
37+
expect( 7 );
3838

39-
// Dialogs are expected to be hidden on destroy, so make sure they're hidden
40-
// before the test
4139
$( "#dialog1, #form-dialog" ).hide();
42-
4340
domEqual( "#dialog1", function() {
4441
var dialog = $( "#dialog1" ).dialog().dialog( "destroy" );
4542
equal( dialog.parent()[ 0 ], $( "#qunit-fixture" )[ 0 ] );
@@ -50,6 +47,16 @@ test("destroy", function() {
5047
equal( dialog.parent()[ 0 ], $( "#qunit-fixture" )[ 0 ] );
5148
equal( dialog.index(), 2 );
5249
});
50+
51+
// Ensure dimensions are restored (#8119)
52+
$( "#dialog1" ).show().css({
53+
width: "400px",
54+
minHeight: "100px",
55+
height: "200px"
56+
});
57+
domEqual( "#dialog1", function() {
58+
$( "#dialog1" ).dialog().dialog( "destroy" );
59+
});
5360
});
5461

5562
test( "enable/disable disabled", function() {

ui/jquery.ui.dialog.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@ $.widget("ui.dialog", {
8484
},
8585

8686
_create: function() {
87+
this.originalCss = {
88+
display: this.element[0].style.display,
89+
width: this.element[0].style.width,
90+
minHeight: this.element[0].style.minHeight,
91+
height: this.element[0].style.height
92+
};
8793
this.originalTitle = this.element.attr( "title" );
8894
this.options.title = this.options.title || this.originalTitle;
8995
this.oldPosition = {
@@ -127,12 +133,7 @@ $.widget("ui.dialog", {
127133
this.element
128134
.removeUniqueId()
129135
.removeClass( "ui-dialog-content ui-widget-content" )
130-
.css({
131-
width: "",
132-
minHeight: "",
133-
height: ""
134-
})
135-
.hide()
136+
.css( this.originalCss )
136137
// without detaching first, the following becomes really slow
137138
.detach();
138139

0 commit comments

Comments
 (0)
0