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.

This commit is contained in:
Scott González 2013-02-01 08:59:55 -05:00
parent 62cda1f95d
commit 7bbda71a32
3 changed files with 12 additions and 1 deletions

View File

@ -16,6 +16,7 @@
<link rel="stylesheet" href="../demos.css"> <link rel="stylesheet" href="../demos.css">
<script> <script>
$(function() { $(function() {
Array.prototype.test = $.noop;
$( "#dialog" ).dialog(); $( "#dialog" ).dialog();
}); });
</script> </script>

View File

@ -174,6 +174,16 @@ test("buttons - advanced", function() {
element.remove(); 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() { test("closeOnEscape", function() {
expect( 6 ); expect( 6 );
var element = $("<div></div>").dialog({ closeOnEscape: false }); var element = $("<div></div>").dialog({ closeOnEscape: false });

View File

@ -396,7 +396,7 @@ $.widget( "ui.dialog", {
this.uiDialogButtonPane.remove(); this.uiDialogButtonPane.remove();
this.uiButtonSet.empty(); this.uiButtonSet.empty();
if ( $.isEmptyObject( buttons ) ) { if ( $.isEmptyObject( buttons ) || ($.isArray( buttons ) && !buttons.length) ) {
this.uiDialog.removeClass("ui-dialog-buttons"); this.uiDialog.removeClass("ui-dialog-buttons");
return; return;
} }