Skip to content

Commit 6c754b4

Browse files
committed
Dialog: Support deprecated button options
Fixes #15016 Closes jquerygh-1723
1 parent f67f929 commit 6c754b4

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

tests/unit/dialog/deprecated.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,34 @@ QUnit.test( "dialogClass", function( assert ) {
2828
element.remove();
2929
} );
3030

31+
QUnit.test( "buttons - deprecated options", function( assert ) {
32+
assert.expect( 7 );
33+
34+
var buttons,
35+
element = $( "<div></div>" ).dialog( {
36+
buttons: [
37+
{
38+
html: "a button",
39+
"class": "additional-class",
40+
id: "my-button-id",
41+
click: function() {
42+
assert.equal( this, element[ 0 ], "correct context" );
43+
},
44+
icons: { primary: "ui-icon-cancel" },
45+
text: false
46+
}
47+
]
48+
} );
49+
50+
buttons = element.dialog( "widget" ).find( ".ui-dialog-buttonpane button" );
51+
assert.equal( buttons.length, 1, "correct number of buttons" );
52+
assert.equal( buttons.attr( "id" ), "my-button-id", "correct id" );
53+
assert.equal( $.trim( buttons.text() ), "a button", "correct label" );
54+
assert.hasClasses( buttons, "additional-class" );
55+
assert.deepEqual( buttons.button( "option", "icon" ), "ui-icon-cancel" );
56+
assert.equal( buttons.button( "option", "showLabel" ), false );
57+
buttons.trigger( "click" );
58+
59+
element.remove();
60+
} );
3161
} );

ui/widgets/dialog.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,14 +500,24 @@ $.widget( "ui.dialog", {
500500
buttonOptions = {
501501
icon: props.icon,
502502
iconPosition: props.iconPosition,
503-
showLabel: props.showLabel
503+
showLabel: props.showLabel,
504+
505+
// Deprecated options
506+
icons: props.icons,
507+
text: props.text
504508
};
505509

506510
delete props.click;
507511
delete props.icon;
508512
delete props.iconPosition;
509513
delete props.showLabel;
510514

515+
// Deprecated options
516+
delete props.icons;
517+
if ( typeof props.text === "boolean" ) {
518+
delete props.text;
519+
}
520+
511521
$( "<button></button>", props )
512522
.button( buttonOptions )
513523
.appendTo( that.uiButtonSet )

0 commit comments

Comments
 (0)