Skip to content

Commit

Permalink
Dialog: Check for empty array in addition to empty object when checki…
Browse files Browse the repository at this point in the history
…ng if there are buttons. Fixes #9043 - Dialog: Buttonpane shown with no buttons when modifying native prototypes.
  • Loading branch information
scottgonzalez committed Feb 1, 2013
1 parent 62cda1f commit 7bbda71
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions demos/dialog/default.html
Expand Up @@ -16,6 +16,7 @@
<link rel="stylesheet" href="../demos.css">
<script>
$(function() {
Array.prototype.test = $.noop;
$( "#dialog" ).dialog();
});
</script>
Expand Down
10 changes: 10 additions & 0 deletions tests/unit/dialog/dialog_options.js
Expand Up @@ -174,6 +174,16 @@ test("buttons - advanced", function() {
element.remove();
});

test("#9043: buttons with Array.prototype modification", function() {
expect( 1 );
Array.prototype.test = $.noop;
var element = $( "<div></div>" ).dialog();
equal( element.dialog( "widget" ).find( ".ui-dialog-buttonpane" ).length, 0,
"no button pane" );
element.remove();
delete Array.prototype.test;
});

test("closeOnEscape", function() {
expect( 6 );
var element = $("<div></div>").dialog({ closeOnEscape: false });
Expand Down
2 changes: 1 addition & 1 deletion ui/jquery.ui.dialog.js
Expand Up @@ -396,7 +396,7 @@ $.widget( "ui.dialog", {
this.uiDialogButtonPane.remove();
this.uiButtonSet.empty();

if ( $.isEmptyObject( buttons ) ) {
if ( $.isEmptyObject( buttons ) || ($.isArray( buttons ) && !buttons.length) ) {
this.uiDialog.removeClass("ui-dialog-buttons");
return;
}
Expand Down

0 comments on commit 7bbda71

Please sign in to comment.