Skip to content
Permalink
Browse files

Dialog: Check for empty array in addition to empty object when checki…

…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 7bbda71a32cc4953715ed34eab2ab48c5e736154
Showing with 12 additions and 1 deletion.
  1. +1 −0 demos/dialog/default.html
  2. +10 −0 tests/unit/dialog/dialog_options.js
  3. +1 −1 ui/jquery.ui.dialog.js
@@ -16,6 +16,7 @@
<link rel="stylesheet" href="../demos.css">
<script>
$(function() {
Array.prototype.test = $.noop;
$( "#dialog" ).dialog();
});
</script>
@@ -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 });
@@ -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;
}

0 comments on commit 7bbda71

Please sign in to comment.
You can’t perform that action at this time.