Skip to content

Commit 7bbda71

Browse files
committed
Dialog: Check for empty array in addition to empty object when checking if there are buttons. Fixes #9043 - Dialog: Buttonpane shown with no buttons when modifying native prototypes.
1 parent 62cda1f commit 7bbda71

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

demos/dialog/default.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<link rel="stylesheet" href="../demos.css">
1717
<script>
1818
$(function() {
19+
Array.prototype.test = $.noop;
1920
$( "#dialog" ).dialog();
2021
});
2122
</script>

tests/unit/dialog/dialog_options.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,16 @@ test("buttons - advanced", function() {
174174
element.remove();
175175
});
176176

177+
test("#9043: buttons with Array.prototype modification", function() {
178+
expect( 1 );
179+
Array.prototype.test = $.noop;
180+
var element = $( "<div></div>" ).dialog();
181+
equal( element.dialog( "widget" ).find( ".ui-dialog-buttonpane" ).length, 0,
182+
"no button pane" );
183+
element.remove();
184+
delete Array.prototype.test;
185+
});
186+
177187
test("closeOnEscape", function() {
178188
expect( 6 );
179189
var element = $("<div></div>").dialog({ closeOnEscape: false });

ui/jquery.ui.dialog.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ $.widget( "ui.dialog", {
396396
this.uiDialogButtonPane.remove();
397397
this.uiButtonSet.empty();
398398

399-
if ( $.isEmptyObject( buttons ) ) {
399+
if ( $.isEmptyObject( buttons ) || ($.isArray( buttons ) && !buttons.length) ) {
400400
this.uiDialog.removeClass("ui-dialog-buttons");
401401
return;
402402
}

0 commit comments

Comments
 (0)