Be sure to clean up the previous test.
[jquery.git] / test / unit / css.js
index 632464b..8f24e2e 100644 (file)
@@ -1,7 +1,7 @@
 module("css");
 
 test("css(String|Hash)", function() {
-       expect(34);
+       expect(42);
 
        equals( jQuery('#main').css("display"), 'block', 'Check for css property "display"');
 
@@ -11,6 +11,26 @@ test("css(String|Hash)", function() {
        jQuery('#nothiddendiv').css({display: 'block'});
        ok( jQuery('#nothiddendiv').is(':visible'), 'Modified CSS display: Assert element is visible');
 
+       var div = jQuery( "<div>" );
+
+       equals( div.css("width"), "0px", "Width on disconnected node." );
+       equals( div.css("height"), "0px", "Height on disconnected node." );
+
+       div.css({ width: 4, height: 4 });
+
+       equals( div.css("width"), "4px", "Width on disconnected node." );
+       equals( div.css("height"), "4px", "Height on disconnected node." );
+
+       var div2 = jQuery( "<div style='display:none;'><input type='text'/><textarea/></div>").appendTo("body");
+
+       equals( div2.find("input").css("width"), "0px", "Width on hidden input." );
+       equals( div2.find("input").css("height"), "0px", "Height on hidden input." );
+
+       equals( div2.find("textarea").css("width"), "0px", "Width on hidden textarea." );
+       equals( div2.find("textarea").css("height"), "0px", "Height on hidden textarea." );
+
+       div2.remove();
+
        // handle negative numbers by ignoring #1599, #4216
        jQuery('#nothiddendiv').css({ 'width': 1, 'height': 1 });
 
@@ -113,9 +133,8 @@ test("css(String, Object)", function() {
 
        // using contents will get comments regular, text, and comment nodes
        var j = jQuery("#nonnodes").contents();
-       j.css("padding-left", "1px");
-       equals( j.css("padding-left"), "1px", "Check node,textnode,comment css works" );
-
+       j.css("overflow", "visible");
+       equals( j.css("overflow"), "visible", "Check node,textnode,comment css works" );
        // opera sometimes doesn't update 'display' correctly, see #2037
        jQuery("#t2037")[0].innerHTML = jQuery("#t2037")[0].innerHTML
        equals( jQuery("#t2037 .hidden").css("display"), "none", "Make sure browser thinks it is hidden" );
@@ -138,7 +157,7 @@ test("css(String, Object)", function() {
        ok( success, "Setting RGBA values does not throw Error" );
 });
 
-if(jQuery.browser.msie) {
+if ( !jQuery.support.opacity ) {
   test("css(String, Object) for MSIE", function() {
     // for #1438, IE throws JS error when filter exists but doesn't have opacity in it
                jQuery('#foo').css("filter", "progid:DXImageTransform.Microsoft.Chroma(color='red');");
@@ -300,4 +319,4 @@ test(":visible selector works properly on children with a hidden parent (bug #45
        expect(1);
        jQuery('#table').css('display', 'none').html('<tr><td>cell</td><td>cell</td></tr>');
        equals(jQuery('#table td:visible').length, 0, "hidden cell children not perceived as visible");
-});
\ No newline at end of file
+});