aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit/css.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/unit/css.js')
-rw-r--r--test/unit/css.js183
1 files changed, 60 insertions, 123 deletions
diff --git a/test/unit/css.js b/test/unit/css.js
index 7f4addded..9e7949f70 100644
--- a/test/unit/css.js
+++ b/test/unit/css.js
@@ -521,14 +521,14 @@ test("show(); hide()", function() {
hiddendiv = jQuery("div.hidden");
hiddendiv.hide();
- equal( hiddendiv.css("display"), "none", "Non-detached div hidden" );
+ equal( hiddendiv.css("display"), "none", "Cascade-hidden div after hide()" );
hiddendiv.show();
- equal( hiddendiv.css("display"), "block", "Pre-hidden div shown" );
+ equal( hiddendiv.css("display"), "none", "Show does not trump CSS cascade" );
div = jQuery("<div>").hide();
equal( div.css("display"), "none", "Detached div hidden" );
div.appendTo("#qunit-fixture").show();
- equal( div.css("display"), "block", "Pre-hidden div shown" );
+ equal( div.css("display"), "block", "Initially-detached div after show()" );
});
@@ -537,7 +537,7 @@ test("show();", function() {
expect( 18 );
var hiddendiv, div, pass, test;
- hiddendiv = jQuery("div.hidden");
+ hiddendiv = jQuery("div.hidden");
equal(jQuery.css( hiddendiv[0], "display"), "none", "hiddendiv is display: none");
@@ -558,8 +558,15 @@ test("show();", function() {
});
ok( pass, "Show" );
- // #show-tests * is set display: none in CSS
- jQuery("#qunit-fixture").append("<div id='show-tests'><div><p><a href='#'></a></p><code></code><pre></pre><span></span></div><table><thead><tr><th></th></tr></thead><tbody><tr><td></td></tr></tbody></table><ul><li></li></ul></div>");
+ jQuery(
+ "<div id='show-tests'>" +
+ "<div><p><a href='#'></a></p><code></code><pre></pre><span></span></div>" +
+ "<table><thead><tr><th></th></tr></thead><tbody><tr><td></td></tr></tbody></table>" +
+ "<ul><li></li></ul></div>" +
+ "<table id='test-table'></table>"
+ ).appendTo( "#qunit-fixture" ).find( "*" ).css( "display", "none" );
+
+ jQuery("#test-table").remove();
test = {
"div" : "block",
@@ -588,135 +595,88 @@ test("show();", function() {
jQuery("<div>test</div> text <span>test</span>").hide().remove();
});
-test("show() resolves correct default display #8099", function() {
- expect(7);
- var tt8099 = jQuery("<tt/>").appendTo("body"),
- dfn8099 = jQuery("<dfn/>", { "html": "foo"}).appendTo("body");
-
- equal( tt8099.css("display"), "none", "default display override for all tt" );
- equal( tt8099.show().css("display"), "inline", "Correctly resolves display:inline" );
-
- equal( jQuery("#foo").hide().show().css("display"), "block", "Correctly resolves display:block after hide/show" );
-
- equal( tt8099.hide().css("display"), "none", "default display override for all tt" );
- equal( tt8099.show().css("display"), "inline", "Correctly resolves display:inline" );
-
- equal( dfn8099.css("display"), "none", "default display override for all dfn" );
- equal( dfn8099.show().css("display"), "inline", "Correctly resolves display:inline" );
-
- tt8099.remove();
- dfn8099.remove();
-});
-
test( "show() resolves correct default display for detached nodes", function(){
- expect( 13 );
+ expect( 16 );
- var div, span, tr, trDisplay;
+ var div, span, tr;
div = jQuery("<div class='hidden'>");
div.show().appendTo("#qunit-fixture");
- equal( div.css("display"), "block", "Make sure a detached, pre-hidden( through stylesheets ) div is visible." );
+ equal( div.css("display"), "none",
+ "A shown-while-detached div can be hidden by the CSS cascade" );
- div = jQuery("<div style='display: none'>");
+ div = jQuery("<div><div class='hidden'></div></div>").children("div");
div.show().appendTo("#qunit-fixture");
- equal( div.css("display"), "block", "Make sure a detached, pre-hidden( through inline style ) div is visible." );
+ equal( div.css("display"), "none",
+ "A shown-while-detached div inside a visible div can be hidden by the CSS cascade" );
span = jQuery("<span class='hidden'/>");
span.show().appendTo("#qunit-fixture");
- equal( span.css("display"), "inline", "Make sure a detached, pre-hidden( through stylesheets ) span has default display." );
-
- span = jQuery("<span style='display: inline'/>");
- span.show().appendTo("#qunit-fixture");
- equal( span.css("display"), "inline", "Make sure a detached, pre-hidden( through inline style ) span has default display." );
-
- div = jQuery("<div><div class='hidden'></div></div>").children("div");
- div.show().appendTo("#qunit-fixture");
- equal( div.css("display"), "block", "Make sure a detached, pre-hidden( through stylesheets ) div inside another visible div is visible." );
-
- div = jQuery("<div><div style='display: none'></div></div>").children("div");
- div.show().appendTo("#qunit-fixture");
- equal( div.css("display"), "block", "Make sure a detached, pre-hidden( through inline style ) div inside another visible div is visible." );
+ equal( span.css("display"), "none",
+ "A shown-while-detached span can be hidden by the CSS cascade" );
div = jQuery("div.hidden");
div.detach().show();
- equal( div.css("display"), "block", "Make sure a detached( through detach() ), pre-hidden div is visible." );
+ ok( !div[ 0 ].style.display,
+ "show() does not update inline style of a cascade-hidden-before-detach div" );
+ div.appendTo("#qunit-fixture");
+ equal( div.css("display"), "none",
+ "A shown-while-detached cascade-hidden div is hidden after attachment" );
div.remove();
- span = jQuery("<span>");
- span.appendTo("#qunit-fixture").detach().show().appendTo("#qunit-fixture" );
- equal( span.css("display"), "inline", "Make sure a detached( through detach() ), pre-hidden span has default display." );
+ span = jQuery("<span class='hidden'/>");
+ span.appendTo("#qunit-fixture").detach().show().appendTo("#qunit-fixture");
+ equal( span.css("display"), "none",
+ "A shown-while-detached cascade-hidden span is hidden after attachment" );
span.remove();
- div = jQuery("<div>");
+ div = jQuery( document.createElement("div") );
div.show().appendTo("#qunit-fixture");
- ok( !!div.get( 0 ).style.display, "Make sure not hidden div has a inline style." );
+ ok( !div[ 0 ].style.display, "A shown-while-detached div has no inline style" );
+ equal( div.css("display"), "block",
+ "A shown-while-detached div has default display after attachment" );
div.remove();
- div = jQuery( document.createElement("div") );
+ div = jQuery("<div style='display: none'>");
+ div.show();
+ equal( div[ 0 ].style.display, "",
+ "show() updates inline style of a detached inline-hidden div" );
+ div.appendTo("#qunit-fixture");
+ equal( div.css("display"), "block",
+ "A shown-while-detached inline-hidden div has default display after attachment" );
+
+ div = jQuery("<div><div style='display: none'></div></div>").children("div");
div.show().appendTo("#qunit-fixture");
- equal( div.css("display"), "block", "Make sure a pre-created element has default display." );
- div.remove();
+ equal( div.css("display"), "block",
+ "A shown-while-detached inline-hidden div inside a visible div has default display " +
+ "after attachment" );
+
+ span = jQuery("<span style='display: none'/>");
+ span.show();
+ equal( span[ 0 ].style.display, "",
+ "show() updates inline style of a detached inline-hidden span" );
+ span.appendTo("#qunit-fixture");
+ equal( span.css("display"), "inline",
+ "A shown-while-detached inline-hidden span has default display after attachment" );
div = jQuery("<div style='display: inline'/>");
div.show().appendTo("#qunit-fixture");
- equal( div.css("display"), "inline", "Make sure that element has same display when it was created." );
+ equal( div.css("display"), "inline",
+ "show() does not update inline style of a detached inline-visible div" );
div.remove();
tr = jQuery("<tr/>");
jQuery("#table").append( tr );
- trDisplay = tr.css( "display" );
tr.detach().hide().show();
- equal( tr[ 0 ].style.display, trDisplay, "For detached tr elements, display should always be like for attached trs" );
+ ok( !tr[ 0 ].style.display, "Not-hidden detached tr elements have no inline style" );
tr.remove();
span = jQuery("<span/>").hide().show();
- equal( span[ 0 ].style.display, "inline", "For detached span elements, display should always be inline" );
+ ok( !span[ 0 ].style.display, "Not-hidden detached span elements have no inline style" );
span.remove();
});
-test("show() resolves correct default display #10227", 4, function() {
- var htmlDisplay,
- html = jQuery( document.documentElement ),
- body = jQuery( "body" );
-
- body.append( "<p class='ddisplay'>a<style>body{display:none}</style></p>" );
-
- equal( body.css("display"), "none", "Initial display for body element: none" );
-
- body.show();
- equal( body.css("display"), "block", "Correct display for body element: block" );
-
- body.append( "<p class='ddisplay'>a<style>html{display:none}</style></p>" );
-
- equal( html.css("display"), "none", "Initial display for html element: none" );
-
- html.show();
- htmlDisplay = html.css( "display" );
-
- // Check for "inline" value needed for older browsers
- ok( "inline" === htmlDisplay || "block" === htmlDisplay, "Correct display for html element" );
-
- jQuery._removeData( body[ 0 ] );
- jQuery._removeData( html[ 0 ] );
- jQuery( ".ddisplay" ).remove();
-});
-
-test("show() resolves correct default display when iframe display:none #12904", function() {
- expect(2);
-
- var ddisplay = jQuery(
- "<p id='ddisplay'>a<style>p{display:none}iframe{display:none !important}</style></p>"
- ).appendTo("body");
-
- equal( ddisplay.css("display"), "none", "Initial display: none" );
-
- ddisplay.show();
- equal( ddisplay.css("display"), "block", "Correct display: block" );
-
- ddisplay.remove();
-});
-
test("toggle()", function() {
expect(9);
var div, oldHide,
@@ -756,7 +716,7 @@ test("hide hidden elements (bug #7141)", function() {
var div = jQuery("<div style='display:none'></div>").appendTo("#qunit-fixture");
equal( div.css("display"), "none", "Element is hidden by default" );
div.hide();
- ok( !jQuery._data(div, "olddisplay"), "olddisplay is undefined after hiding an already-hidden element" );
+ ok( !jQuery._data(div, "display"), "display data is undefined after hiding an already-hidden element" );
div.show();
equal( div.css("display"), "block", "Show a double-hidden element" );
@@ -1156,29 +1116,6 @@ asyncTest( "Clearing a Cloned Element's Style Shouldn't Clear the Original Eleme
window.setTimeout( start, 1000 );
});
-asyncTest( "Make sure initialized display value for disconnected nodes is correct (#13310)", 4, function() {
- var display = jQuery("#display").css("display"),
- div = jQuery("<div/>");
-
- equal( div.css( "display", "inline" ).hide().show().appendTo("body").css( "display" ), "inline", "Initialized display value has returned" );
- div.remove();
-
- div.css( "display", "none" ).hide();
- equal( jQuery._data( div[ 0 ], "olddisplay" ), undefined, "olddisplay is undefined after hiding a detached and hidden element" );
- div.remove();
-
- div.css( "display", "inline-block" ).hide().appendTo("body").fadeIn(function() {
- equal( div.css( "display" ), "inline-block", "Initialized display value has returned" );
- div.remove();
-
- start();
- });
-
- equal( jQuery._data( jQuery("#display").css( "display", "inline" ).hide()[ 0 ], "olddisplay" ), display,
- "display: * !Important value should used as initialized display" );
- jQuery._removeData( jQuery("#display")[ 0 ] );
-});
-
test( "show() after hide() should always set display to initial value (#14750)", 1, function() {
var div = jQuery( "<div />" ),
fixture = jQuery( "#qunit-fixture" );