1 module("dimensions", { teardown: moduleTeardown });
8 return function(){ return val; };
11 function testWidth( val ) {
14 var $div = jQuery("#nothiddendiv");
15 $div.width( val(30) );
16 equals($div.width(), 30, "Test set to 30 correctly");
18 equals($div.width(), 30, "Test hidden div");
20 $div.width( val(-1) ); // handle negative numbers by ignoring #1599
21 equals($div.width(), 30, "Test negative width ignored");
22 $div.css("padding", "20px");
23 equals($div.width(), 30, "Test padding specified with pixels");
24 $div.css("border", "2px solid #fff");
25 equals($div.width(), 30, "Test border specified with pixels");
27 $div.css({ display: "", border: "", padding: "" });
29 jQuery("#nothiddendivchild").css({ width: 20, padding: "3px", border: "2px solid #fff" });
30 equals(jQuery("#nothiddendivchild").width(), 20, "Test child width with border and padding");
31 jQuery("#nothiddendiv, #nothiddendivchild").css({ border: "", padding: "", width: "" });
33 var blah = jQuery("blah");
34 equals( blah.width( val(10) ), blah, "Make sure that setting a width on an empty set returns the set." );
35 equals( blah.width(), null, "Make sure 'null' is returned on an empty set");
37 jQuery.removeData($div[0], 'olddisplay', true);
40 test("width()", function() {
44 test("width() with function", function() {
48 test("width() with function args", function() {
51 var $div = jQuery("#nothiddendiv");
52 $div.width( 30 ).width(function(i, width) {
53 equals( width, 30, "Make sure previous value is corrrect." );
57 equals( $div.width(), 31, "Make sure value was modified correctly." );
60 function testHeight( val ) {
63 var $div = jQuery("#nothiddendiv");
64 $div.height( val(30) );
65 equals($div.height(), 30, "Test set to 30 correctly");
67 equals($div.height(), 30, "Test hidden div");
69 $div.height( val(-1) ); // handle negative numbers by ignoring #1599
70 equals($div.height(), 30, "Test negative height ignored");
71 $div.css("padding", "20px");
72 equals($div.height(), 30, "Test padding specified with pixels");
73 $div.css("border", "2px solid #fff");
74 equals($div.height(), 30, "Test border specified with pixels");
76 $div.css({ display: "", border: "", padding: "", height: "1px" });
78 jQuery("#nothiddendivchild").css({ height: 20, padding: "3px", border: "2px solid #fff" });
79 equals(jQuery("#nothiddendivchild").height(), 20, "Test child height with border and padding");
80 jQuery("#nothiddendiv, #nothiddendivchild").css({ border: "", padding: "", height: "" });
82 var blah = jQuery("blah");
83 equals( blah.height( val(10) ), blah, "Make sure that setting a height on an empty set returns the set." );
84 equals( blah.height(), null, "Make sure 'null' is returned on an empty set");
86 jQuery.removeData($div[0], 'olddisplay', true);
89 test("height()", function() {
93 test("height() with function", function() {
97 test("height() with function args", function() {
100 var $div = jQuery("#nothiddendiv");
101 $div.height( 30 ).height(function(i, height) {
102 equals( height, 30, "Make sure previous value is corrrect." );
106 equals( $div.height(), 31, "Make sure value was modified correctly." );
109 test("innerWidth()", function() {
112 var $div = jQuery("#nothiddendiv");
116 border: "2px solid #fff",
120 equals($div.innerWidth(), 30, "Test with margin and border");
121 $div.css("padding", "20px");
122 equals($div.innerWidth(), 70, "Test with margin, border and padding");
124 equals($div.innerWidth(), 70, "Test hidden div");
127 $div.css({ display: "", border: "", padding: "", width: "", height: "" });
129 var div = jQuery( "<div>" );
131 // Temporarily require 0 for backwards compat - should be auto
132 equals( div.innerWidth(), 0, "Make sure that disconnected nodes are handled." );
135 jQuery.removeData($div[0], 'olddisplay', true);
138 test("innerHeight()", function() {
141 var $div = jQuery("#nothiddendiv");
145 border: "2px solid #fff",
149 equals($div.innerHeight(), 30, "Test with margin and border");
150 $div.css("padding", "20px");
151 equals($div.innerHeight(), 70, "Test with margin, border and padding");
153 equals($div.innerHeight(), 70, "Test hidden div");
156 $div.css({ display: "", border: "", padding: "", width: "", height: "" });
158 var div = jQuery( "<div>" );
160 // Temporarily require 0 for backwards compat - should be auto
161 equals( div.innerHeight(), 0, "Make sure that disconnected nodes are handled." );
164 jQuery.removeData($div[0], 'olddisplay', true);
167 test("outerWidth()", function() {
170 var $div = jQuery("#nothiddendiv");
171 $div.css("width", 30);
173 equals($div.outerWidth(), 30, "Test with only width set");
174 $div.css("padding", "20px");
175 equals($div.outerWidth(), 70, "Test with padding");
176 $div.css("border", "2px solid #fff");
177 equals($div.outerWidth(), 74, "Test with padding and border");
178 $div.css("margin", "10px");
179 equals($div.outerWidth(), 74, "Test with padding, border and margin without margin option");
180 $div.css("position", "absolute");
181 equals($div.outerWidth(true), 94, "Test with padding, border and margin with margin option");
183 equals($div.outerWidth(true), 94, "Test hidden div with padding, border and margin with margin option");
186 $div.css({ position: "", display: "", border: "", padding: "", width: "", height: "" });
188 var div = jQuery( "<div>" );
190 // Temporarily require 0 for backwards compat - should be auto
191 equals( div.outerWidth(), 0, "Make sure that disconnected nodes are handled." );
194 jQuery.removeData($div[0], 'olddisplay', true);
197 test("outerHeight()", function() {
200 var $div = jQuery("#nothiddendiv");
201 $div.css("height", 30);
203 equals($div.outerHeight(), 30, "Test with only width set");
204 $div.css("padding", "20px");
205 equals($div.outerHeight(), 70, "Test with padding");
206 $div.css("border", "2px solid #fff");
207 equals($div.outerHeight(), 74, "Test with padding and border");
208 $div.css("margin", "10px");
209 equals($div.outerHeight(), 74, "Test with padding, border and margin without margin option");
210 equals($div.outerHeight(true), 94, "Test with padding, border and margin with margin option");
212 equals($div.outerHeight(true), 94, "Test hidden div with padding, border and margin with margin option");
215 $div.css({ display: "", border: "", padding: "", width: "", height: "" });
217 var div = jQuery( "<div>" );
219 // Temporarily require 0 for backwards compat - should be auto
220 equals( div.outerHeight(), 0, "Make sure that disconnected nodes are handled." );
223 jQuery.removeData($div[0], 'olddisplay', true);