Skip to content

Commit e960918

Browse files
committed
Dialog: Refactor _setOption to call _super early. Move dialogClass update above that to access old option value.
1 parent eae645c commit e960918

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

tests/unit/dialog/dialog_options.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,14 +148,17 @@ test("closeText", function() {
148148
});
149149

150150
test("dialogClass", function() {
151-
expect(4);
151+
expect( 6 );
152152

153153
var el = $('<div></div>').dialog();
154154
equal(el.dialog('widget').is(".foo"), false, 'dialogClass not specified. foo class added');
155155
el.remove();
156156

157157
el = $('<div></div>').dialog({ dialogClass: "foo" });
158158
equal(el.dialog('widget').is(".foo"), true, 'dialogClass in init. foo class added');
159+
el.dialog( "option", "dialogClass", "foobar" );
160+
equal( el.dialog('widget').is(".foo"), false, "dialogClass changed, previous one was removed" );
161+
equal( el.dialog('widget').is(".foobar"), true, "dialogClass changed, new one was added" );
159162
el.remove();
160163

161164
el = $('<div></div>').dialog({ dialogClass: "foo bar" });

ui/jquery.ui.dialog.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,14 @@ $.widget("ui.dialog", {
565565
var isDraggable, isResizable,
566566
uiDialog = this.uiDialog;
567567

568+
if ( key === "dialogClass" ) {
569+
uiDialog
570+
.removeClass( this.options.dialogClass )
571+
.addClass( value );
572+
}
573+
574+
this._super( key, value );
575+
568576
switch ( key ) {
569577
case "buttons":
570578
this._createButtons( value );
@@ -575,11 +583,6 @@ $.widget("ui.dialog", {
575583
label: "" + value
576584
});
577585
break;
578-
case "dialogClass":
579-
uiDialog
580-
.removeClass( this.options.dialogClass )
581-
.addClass( value );
582-
break;
583586
case "disabled":
584587
// TODO use toggleClass( "ui-dialog-disabled", value )
585588
if ( value ) {
@@ -625,8 +628,6 @@ $.widget("ui.dialog", {
625628
.html( "" + ( value || "&#160;" ) );
626629
break;
627630
}
628-
629-
this._super( key, value );
630631
},
631632

632633
_size: function() {

0 commit comments

Comments
 (0)