]> source.dussan.org Git - jquery-ui.git/commitdiff
Dialog: Restore inline styles for dimensions/display. Fixes #8119 - Dialog: Destroyin...
authorScott González <scott.gonzalez@gmail.com>
Wed, 5 Dec 2012 16:53:34 +0000 (11:53 -0500)
committerScott González <scott.gonzalez@gmail.com>
Wed, 5 Dec 2012 16:53:34 +0000 (11:53 -0500)
tests/unit/dialog/dialog_methods.js
ui/jquery.ui.dialog.js

index 6eeb50273e5274c678035c2ddafb606f6ff4f4a7..92fe3d60f65c25750f194209ab21a456a741e086 100644 (file)
@@ -34,12 +34,9 @@ test("init", 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();
-
        domEqual( "#dialog1", function() {
                var dialog = $( "#dialog1" ).dialog().dialog( "destroy" );
                equal( dialog.parent()[ 0 ], $( "#qunit-fixture" )[ 0 ] );
@@ -50,6 +47,16 @@ test("destroy", function() {
                equal( dialog.parent()[ 0 ], $( "#qunit-fixture" )[ 0 ] );
                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() {
index 96c9986567eb66139e983c80ecc4a64bfe692512..eac818fe0e12a042c6e22f55450199132ba5b923 100644 (file)
@@ -84,6 +84,12 @@ $.widget("ui.dialog", {
        },
 
        _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.options.title = this.options.title || this.originalTitle;
                this.oldPosition = {
@@ -127,12 +133,7 @@ $.widget("ui.dialog", {
                this.element
                        .removeUniqueId()
                        .removeClass( "ui-dialog-content ui-widget-content" )
-                       .css({
-                               width: "",
-                               minHeight: "",
-                               height: ""
-                       })
-                       .hide()
+                       .css( this.originalCss )
                        // without detaching first, the following becomes really slow
                        .detach();