]> source.dussan.org Git - jquery-ui.git/commitdiff
Dialog: Check for empty array in addition to empty object when checking if there...
authorScott González <scott.gonzalez@gmail.com>
Fri, 1 Feb 2013 13:59:55 +0000 (08:59 -0500)
committerScott González <scott.gonzalez@gmail.com>
Fri, 1 Feb 2013 13:59:55 +0000 (08:59 -0500)
demos/dialog/default.html
tests/unit/dialog/dialog_options.js
ui/jquery.ui.dialog.js

index e781e18f84b3bfd3919a9afabdf4b8d5f96d743b..98f248b81ed68fd81c8bcfe8acd9e9d435c5aace 100644 (file)
@@ -16,6 +16,7 @@
        <link rel="stylesheet" href="../demos.css">
        <script>
        $(function() {
+               Array.prototype.test = $.noop;
                $( "#dialog" ).dialog();
        });
        </script>
index a295b904d72eb1d5a3670685fa4352159d026fe6..07c2d6860694102ed3bc3cfc7f947ff58d6e3388 100644 (file)
@@ -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 });
index b6ac7aed7b4477e68e4d0dde6ab72392e7ada9cd..cb62155e5908c891433aa97c4b76107561af3edf 100644 (file)
@@ -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;
                }