]> source.dussan.org Git - jquery-ui.git/commitdiff
Dialog: Refactor _setOption to call _super early. Move dialogClass update above that...
authorJörn Zaefferer <joern.zaefferer@gmail.com>
Thu, 15 Nov 2012 21:51:26 +0000 (22:51 +0100)
committerJörn Zaefferer <joern.zaefferer@gmail.com>
Fri, 16 Nov 2012 09:43:36 +0000 (10:43 +0100)
tests/unit/dialog/dialog_options.js
ui/jquery.ui.dialog.js

index 2df7196dc8455b5cab8efe842132e64bed340437..0be8c2b7fec688d18e7942dfb9408383be3158db 100644 (file)
@@ -148,7 +148,7 @@ test("closeText", function() {
 });
 
 test("dialogClass", function() {
-       expect(4);
+       expect( 6 );
 
        var el = $('<div></div>').dialog();
                equal(el.dialog('widget').is(".foo"), false, 'dialogClass not specified. foo class added');
@@ -156,6 +156,9 @@ test("dialogClass", function() {
 
        el = $('<div></div>').dialog({ dialogClass: "foo" });
                equal(el.dialog('widget').is(".foo"), true, 'dialogClass in init. foo class added');
+       el.dialog( "option", "dialogClass", "foobar" );
+               equal( el.dialog('widget').is(".foo"), false, "dialogClass changed, previous one was removed" );
+               equal( el.dialog('widget').is(".foobar"), true, "dialogClass changed, new one was added" );
        el.remove();
 
        el = $('<div></div>').dialog({ dialogClass: "foo bar" });
index 055040b32a6c10cde562a9ee23be4ffdc6e2c340..cb4230eac959c3b78dfef7d7748aa7a510e8941e 100644 (file)
@@ -565,6 +565,14 @@ $.widget("ui.dialog", {
                var isDraggable, isResizable,
                        uiDialog = this.uiDialog;
 
+               if ( key === "dialogClass" ) {
+                       uiDialog
+                               .removeClass( this.options.dialogClass )
+                               .addClass( value );
+               }
+
+               this._super( key, value );
+
                switch ( key ) {
                        case "buttons":
                                this._createButtons( value );
@@ -575,11 +583,6 @@ $.widget("ui.dialog", {
                                        label: "" + value
                                });
                                break;
-                       case "dialogClass":
-                               uiDialog
-                                       .removeClass( this.options.dialogClass )
-                                       .addClass( value );
-                               break;
                        case "disabled":
                                // TODO use toggleClass( "ui-dialog-disabled", value )
                                if ( value ) {
@@ -625,8 +628,6 @@ $.widget("ui.dialog", {
                                        .html( "" + ( value || "&#160;" ) );
                                break;
                }
-
-               this._super( key, value );
        },
 
        _size: function() {