From 3394d32ea75cffb8c8c386d607823cae878b9145 Mon Sep 17 00:00:00 2001
From: jeresig <jeresig@gmail.com>
Date: Tue, 9 Nov 2010 23:29:26 -0500
Subject: [PATCH] Maintain returning 0px from width/height for disconnected
 nodes for backwards compat, for now. Fixes #7395.

---
 src/css.js              |    9 +++++++--
 test/unit/css.js        |    6 ++++--
 test/unit/dimensions.js |   28 ++++++++++++++++++++++++----
 3 files changed, 35 insertions(+), 8 deletions(-)

diff --git a/src/css.js b/src/css.js
index 4665fa7..369485e 100644
--- a/src/css.js
+++ b/src/css.js
@@ -177,13 +177,18 @@ jQuery.each(["height", "width"], function( i, name ) {
 					}
 
 					if ( val != null ) {
-						return val === "" ? "auto" : val;
+						// Should return "auto" instead of 0, use 0 for
+						// temporary backwards-compat
+						return val === "" ? "0px" : val;
 					}
 				}
 
 				if ( val < 0 || val == null ) {
 					val = elem.style[ name ];
-					return val === "" ? "auto" : val;
+
+					// Should return "auto" instead of 0, use 0 for
+					// temporary backwards-compat
+					return val === "" ? "0px" : val;
 				}
 
 				return typeof val === "string" ? val : val + "px";
diff --git a/test/unit/css.js b/test/unit/css.js
index 71f8835..cddd902 100644
--- a/test/unit/css.js
+++ b/test/unit/css.js
@@ -13,8 +13,10 @@ test("css(String|Hash)", function() {
 
 	var div = jQuery( "<div>" );
 
-	equals( div.css("width"), "auto", "Width on disconnected node." );
-	equals( div.css("height"), "auto", "Height on disconnected node." );
+	// These should be "auto" (or some better value)
+	// temporarily provide "0px" for backwards compat
+	equals( div.css("width"), "0px", "Width on disconnected node." );
+	equals( div.css("height"), "0px", "Height on disconnected node." );
 
 	div.css({ width: 4, height: 4 });
 
diff --git a/test/unit/dimensions.js b/test/unit/dimensions.js
index 92cf17b..8255bf3 100644
--- a/test/unit/dimensions.js
+++ b/test/unit/dimensions.js
@@ -103,7 +103,7 @@ test("height() with function args", function() {
 });
 
 test("innerWidth()", function() {
-	expect(3);
+	expect(4);
 
 	var $div = jQuery("#nothiddendiv");
 	// set styles
@@ -121,10 +121,15 @@ test("innerWidth()", function() {
 	
 	// reset styles
 	$div.css({ display: "", border: "", padding: "", width: "", height: "" });
+
+	var div = jQuery( "<div>" );
+
+	// Temporarily require 0 for backwards compat - should be auto
+	equals( div.innerWidth(), 0, "Make sure that disconnected nodes are handled." );
 });
 
 test("innerHeight()", function() {
-	expect(3);
+	expect(4);
 	
 	var $div = jQuery("#nothiddendiv");
 	// set styles
@@ -142,10 +147,15 @@ test("innerHeight()", function() {
 	
 	// reset styles
 	$div.css({ display: "", border: "", padding: "", width: "", height: "" });
+
+	var div = jQuery( "<div>" );
+
+	// Temporarily require 0 for backwards compat - should be auto
+	equals( div.innerHeight(), 0, "Make sure that disconnected nodes are handled." );
 });
 
 test("outerWidth()", function() {
-	expect(6);
+	expect(7);
 	
 	var $div = jQuery("#nothiddendiv");
 	$div.css("width", 30);
@@ -164,10 +174,15 @@ test("outerWidth()", function() {
 	
 	// reset styles
 	$div.css({ position: "", display: "", border: "", padding: "", width: "", height: "" });
+
+	var div = jQuery( "<div>" );
+
+	// Temporarily require 0 for backwards compat - should be auto
+	equals( div.outerWidth(), 0, "Make sure that disconnected nodes are handled." );
 });
 
 test("outerHeight()", function() {
-	expect(6);
+	expect(7);
 	
 	var $div = jQuery("#nothiddendiv");
 	$div.css("height", 30);
@@ -185,4 +200,9 @@ test("outerHeight()", function() {
 	
 	// reset styles
 	$div.css({ display: "", border: "", padding: "", width: "", height: "" });
+
+	var div = jQuery( "<div>" );
+
+	// Temporarily require 0 for backwards compat - should be auto
+	equals( div.outerHeight(), 0, "Make sure that disconnected nodes are handled." );
 });
-- 
1.7.10.4