mirror of
https://github.com/jquery/jquery-ui.git
synced 2025-01-07 20:34:24 +00:00
Dialog: Refactor _setOption to call _super early. Move dialogClass update above that to access old option value.
This commit is contained in:
parent
83a9f219bf
commit
fed2972027
@ -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" });
|
||||
|
15
ui/jquery.ui.dialog.js
vendored
15
ui/jquery.ui.dialog.js
vendored
@ -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 || " " ) );
|
||||
break;
|
||||
}
|
||||
|
||||
this._super( key, value );
|
||||
},
|
||||
|
||||
_size: function() {
|
||||
|
Loading…
Reference in New Issue
Block a user