]> source.dussan.org Git - jquery-ui.git/commitdiff
Dialog: modified _createOverlay to _appendTo instead of document.body. Fixed #8984...
authorDavid Sullivan <david.sullivan@gmail.com>
Sat, 26 Jan 2013 10:03:14 +0000 (04:03 -0600)
committerMike Sherov <mike.sherov@gmail.com>
Sat, 26 Jan 2013 16:34:51 +0000 (11:34 -0500)
tests/unit/dialog/dialog_options.js
ui/jquery.ui.dialog.js

index a20480de60508b5a9bf8bbf14d44d4d833db45dd..5f043430835619d767a170823359ccbb3790410c 100644 (file)
@@ -6,43 +6,63 @@
 module("dialog: options");
 
 test( "appendTo", function() {
-       expect( 8 );
+       expect( 16 );
        var detached = $( "<div>" ),
-               element = $( "#dialog1" ).dialog();
+               element = $( "#dialog1" ).dialog({
+                       modal: true
+               });
        equal( element.dialog( "widget" ).parent()[0], document.body, "defaults to body" );
+       equal( $( ".ui-widget-overlay" ).parent()[0], document.body, "overlay defaults to body" );
        element.dialog( "destroy" );
 
        element.dialog({
-               appendTo: ".wrap"
+               appendTo: ".wrap",
+               modal: true
        });
        equal( element.dialog( "widget" ).parent()[0], $( "#wrap1" )[0], "first found element" );
+       equal( $( ".ui-widget-overlay" ).parent()[0], $( "#wrap1" )[0], "overlay first found element" );
        equal( $( "#wrap2 .ui-dialog" ).length, 0, "only appends to one element" );
+       equal( $( "#wrap2 .ui-widget-overlay" ).length, 0, "overlay only appends to one element" );
        element.dialog( "destroy" );
 
        element.dialog({
-               appendTo: null
+               appendTo: null,
+               modal: true
        });
        equal( element.dialog( "widget" ).parent()[0], document.body, "null" );
+       equal( $( ".ui-widget-overlay" ).parent()[0], document.body, "overlay null" );
        element.dialog( "destroy" );
 
-       element.dialog({ autoOpen: false }).dialog( "option", "appendTo", "#wrap1" ).dialog( "open" );
+       element.dialog({
+               autoOpen: false,
+               modal: true
+       }).dialog( "option", "appendTo", "#wrap1" ).dialog( "open" );
        equal( element.dialog( "widget" ).parent()[0], $( "#wrap1" )[0], "modified after init" );
+       equal( $( ".ui-widget-overlay" ).parent()[0], $( "#wrap1" )[0], "overlay modified after init" );
        element.dialog( "destroy" );
 
        element.dialog({
-               appendTo: detached
+               appendTo: detached,
+               modal: true
        });
        equal( element.dialog( "widget" ).parent()[0], detached[0], "detached jQuery object" );
+       equal( detached.find( ".ui-widget-overlay" ).parent()[0], detached[0], "overlay detached jQuery object" );
        element.dialog( "destroy" );
 
        element.dialog({
-               appendTo: detached[0]
+               appendTo: detached[0],
+               modal: true
        });
        equal( element.dialog( "widget" ).parent()[0], detached[0], "detached DOM element" );
+       equal( detached.find( ".ui-widget-overlay" ).parent()[0], detached[0], "overlay detached DOM element" );
        element.dialog( "destroy" );
 
-       element.dialog({ autoOpen: false }).dialog( "option", "appendTo", detached );
+       element.dialog({
+               autoOpen: false,
+               modal: true
+       }).dialog( "option", "appendTo", detached );
        equal( element.dialog( "widget" ).parent()[0], detached[0], "detached DOM element via option()" );
+       equal( detached.find( ".ui-widget-overlay" ).length, 0, "overlay detached DOM element via option()" );
        element.dialog( "destroy" );
 });
 
index 1d3a7a88fdf5faacae65da65bc84f2ada6a7d1c8..ec4032ff3b5e208a66b0f439e855b58dc15a19c3 100644 (file)
@@ -695,7 +695,7 @@ $.widget( "ui.dialog", {
 
                this.overlay = $("<div>")
                        .addClass("ui-widget-overlay ui-front")
-                       .appendTo( this.document[0].body );
+                       .appendTo( this._appendTo() );
                this._on( this.overlay, {
                        mousedown: "_keepFocus"
                });