From: Scott González Date: Fri, 1 Feb 2013 13:59:55 +0000 (-0500) Subject: Dialog: Check for empty array in addition to empty object when checking if there... X-Git-Tag: 1.10.1~25 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=7bbda71a32cc4953715ed34eab2ab48c5e736154;p=jquery-ui.git 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. --- diff --git a/demos/dialog/default.html b/demos/dialog/default.html index e781e18f8..98f248b81 100644 --- a/demos/dialog/default.html +++ b/demos/dialog/default.html @@ -16,6 +16,7 @@ diff --git a/tests/unit/dialog/dialog_options.js b/tests/unit/dialog/dialog_options.js index a295b904d..07c2d6860 100644 --- a/tests/unit/dialog/dialog_options.js +++ b/tests/unit/dialog/dialog_options.js @@ -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 = $( "
" ).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 = $("
").dialog({ closeOnEscape: false }); diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js index b6ac7aed7..cb62155e5 100644 --- a/ui/jquery.ui.dialog.js +++ b/ui/jquery.ui.dialog.js @@ -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; }