Skip to content
Permalink
Browse files

Dialog: Refactor _setOption to call _super early. Move dialogClass up…

…date above that to access old option value.
  • Loading branch information...
jzaefferer committed Nov 15, 2012
1 parent 83a9f21 commit fed2972027f362181a614750fbaa7e252d1c1cb2
Showing with 12 additions and 8 deletions.
  1. +4 −1 tests/unit/dialog/dialog_options.js
  2. +8 −7 ui/jquery.ui.dialog.js
@@ -148,14 +148,17 @@ 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');
el.remove();

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" });
@@ -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() {

0 comments on commit fed2972

Please sign in to comment.
You can’t perform that action at this time.