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");
38 test("width()", function() {
42 test("width() with function", function() {
46 test("width() with function args", function() {
49 var $div = jQuery("#nothiddendiv");
50 $div.width( 30 ).width(function(i, width) {
51 equals( width, 30, "Make sure previous value is corrrect." );
55 equals( $div.width(), 31, "Make sure value was modified correctly." );
58 function testHeight( val ) {
61 var $div = jQuery("#nothiddendiv");
62 $div.height( val(30) );
63 equals($div.height(), 30, "Test set to 30 correctly");
65 equals($div.height(), 30, "Test hidden div");
67 $div.height( val(-1) ); // handle negative numbers by ignoring #1599
68 equals($div.height(), 30, "Test negative height ignored");
69 $div.css("padding", "20px");
70 equals($div.height(), 30, "Test padding specified with pixels");
71 $div.css("border", "2px solid #fff");
72 equals($div.height(), 30, "Test border specified with pixels");
74 $div.css({ display: "", border: "", padding: "", height: "1px" });
76 jQuery("#nothiddendivchild").css({ height: 20, padding: "3px", border: "2px solid #fff" });
77 equals(jQuery("#nothiddendivchild").height(), 20, "Test child height with border and padding");
78 jQuery("#nothiddendiv, #nothiddendivchild").css({ border: "", padding: "", height: "" });
80 var blah = jQuery("blah");
81 equals( blah.height( val(10) ), blah, "Make sure that setting a height on an empty set returns the set." );
82 equals( blah.height(), null, "Make sure 'null' is returned on an empty set");
85 test("height()", function() {
89 test("height() with function", function() {
93 test("height() with function args", function() {
96 var $div = jQuery("#nothiddendiv");
97 $div.height( 30 ).height(function(i, height) {
98 equals( height, 30, "Make sure previous value is corrrect." );
102 equals( $div.height(), 31, "Make sure value was modified correctly." );
105 test("innerWidth()", function() {
108 var $div = jQuery("#nothiddendiv");
112 border: "2px solid #fff",
116 equals($div.innerWidth(), 30, "Test with margin and border");
117 $div.css("padding", "20px");
118 equals($div.innerWidth(), 70, "Test with margin, border and padding");
120 equals($div.innerWidth(), 70, "Test hidden div");
123 $div.css({ display: "", border: "", padding: "", width: "", height: "" });
126 test("innerHeight()", function() {
129 var $div = jQuery("#nothiddendiv");
133 border: "2px solid #fff",
137 equals($div.innerHeight(), 30, "Test with margin and border");
138 $div.css("padding", "20px");
139 equals($div.innerHeight(), 70, "Test with margin, border and padding");
141 equals($div.innerHeight(), 70, "Test hidden div");
144 $div.css({ display: "", border: "", padding: "", width: "", height: "" });
147 test("outerWidth()", function() {
150 var $div = jQuery("#nothiddendiv");
151 $div.css("width", 30);
153 equals($div.outerWidth(), 30, "Test with only width set");
154 $div.css("padding", "20px");
155 equals($div.outerWidth(), 70, "Test with padding");
156 $div.css("border", "2px solid #fff");
157 equals($div.outerWidth(), 74, "Test with padding and border");
158 $div.css("margin", "10px");
159 equals($div.outerWidth(), 74, "Test with padding, border and margin without margin option");
160 $div.css("position", "absolute");
161 equals($div.outerWidth(true), 94, "Test with padding, border and margin with margin option");
163 equals($div.outerWidth(true), 94, "Test hidden div with padding, border and margin with margin option");
166 $div.css({ position: "", display: "", border: "", padding: "", width: "", height: "" });
169 test("outerHeight()", function() {
172 var $div = jQuery("#nothiddendiv");
173 $div.css("height", 30);
175 equals($div.outerHeight(), 30, "Test with only width set");
176 $div.css("padding", "20px");
177 equals($div.outerHeight(), 70, "Test with padding");
178 $div.css("border", "2px solid #fff");
179 equals($div.outerHeight(), 74, "Test with padding and border");
180 $div.css("margin", "10px");
181 equals($div.outerHeight(), 74, "Test with padding, border and margin without margin option");
182 equals($div.outerHeight(true), 94, "Test with padding, border and margin with margin option");
184 equals($div.outerHeight(true), 94, "Test hidden div with padding, border and margin with margin option");
187 $div.css({ display: "", border: "", padding: "", width: "", height: "" });