Skip to content

Commit 3394d32

Browse files
committed
Maintain returning 0px from width/height for disconnected nodes for backwards compat, for now. Fixes #7395.
1 parent 795e880 commit 3394d32

File tree

3 files changed

+35
-8
lines changed

3 files changed

+35
-8
lines changed

src/css.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,13 +177,18 @@ jQuery.each(["height", "width"], function( i, name ) {
177177
}
178178

179179
if ( val != null ) {
180-
return val === "" ? "auto" : val;
180+
// Should return "auto" instead of 0, use 0 for
181+
// temporary backwards-compat
182+
return val === "" ? "0px" : val;
181183
}
182184
}
183185

184186
if ( val < 0 || val == null ) {
185187
val = elem.style[ name ];
186-
return val === "" ? "auto" : val;
188+
189+
// Should return "auto" instead of 0, use 0 for
190+
// temporary backwards-compat
191+
return val === "" ? "0px" : val;
187192
}
188193

189194
return typeof val === "string" ? val : val + "px";

test/unit/css.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ test("css(String|Hash)", function() {
1313

1414
var div = jQuery( "<div>" );
1515

16-
equals( div.css("width"), "auto", "Width on disconnected node." );
17-
equals( div.css("height"), "auto", "Height on disconnected node." );
16+
// These should be "auto" (or some better value)
17+
// temporarily provide "0px" for backwards compat
18+
equals( div.css("width"), "0px", "Width on disconnected node." );
19+
equals( div.css("height"), "0px", "Height on disconnected node." );
1820

1921
div.css({ width: 4, height: 4 });
2022

test/unit/dimensions.js

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ test("height() with function args", function() {
103103
});
104104

105105
test("innerWidth()", function() {
106-
expect(3);
106+
expect(4);
107107

108108
var $div = jQuery("#nothiddendiv");
109109
// set styles
@@ -121,10 +121,15 @@ test("innerWidth()", function() {
121121

122122
// reset styles
123123
$div.css({ display: "", border: "", padding: "", width: "", height: "" });
124+
125+
var div = jQuery( "<div>" );
126+
127+
// Temporarily require 0 for backwards compat - should be auto
128+
equals( div.innerWidth(), 0, "Make sure that disconnected nodes are handled." );
124129
});
125130

126131
test("innerHeight()", function() {
127-
expect(3);
132+
expect(4);
128133

129134
var $div = jQuery("#nothiddendiv");
130135
// set styles
@@ -142,10 +147,15 @@ test("innerHeight()", function() {
142147

143148
// reset styles
144149
$div.css({ display: "", border: "", padding: "", width: "", height: "" });
150+
151+
var div = jQuery( "<div>" );
152+
153+
// Temporarily require 0 for backwards compat - should be auto
154+
equals( div.innerHeight(), 0, "Make sure that disconnected nodes are handled." );
145155
});
146156

147157
test("outerWidth()", function() {
148-
expect(6);
158+
expect(7);
149159

150160
var $div = jQuery("#nothiddendiv");
151161
$div.css("width", 30);
@@ -164,10 +174,15 @@ test("outerWidth()", function() {
164174

165175
// reset styles
166176
$div.css({ position: "", display: "", border: "", padding: "", width: "", height: "" });
177+
178+
var div = jQuery( "<div>" );
179+
180+
// Temporarily require 0 for backwards compat - should be auto
181+
equals( div.outerWidth(), 0, "Make sure that disconnected nodes are handled." );
167182
});
168183

169184
test("outerHeight()", function() {
170-
expect(6);
185+
expect(7);
171186

172187
var $div = jQuery("#nothiddendiv");
173188
$div.css("height", 30);
@@ -185,4 +200,9 @@ test("outerHeight()", function() {
185200

186201
// reset styles
187202
$div.css({ display: "", border: "", padding: "", width: "", height: "" });
203+
204+
var div = jQuery( "<div>" );
205+
206+
// Temporarily require 0 for backwards compat - should be auto
207+
equals( div.outerHeight(), 0, "Make sure that disconnected nodes are handled." );
188208
});

0 commit comments

Comments
 (0)