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({ 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." );
37 test("width()", function() {
41 test("width() with function", function() {
45 test("width() with function args", function() {
48 var $div = jQuery("#nothiddendiv");
49 $div.width( 30 ).width(function(i, width) {
50 equals( width, 30, "Make sure previous value is corrrect." );
54 equals( $div.width(), 31, "Make sure value was modified correctly." );
57 function testHeight( val ) {
60 var $div = jQuery("#nothiddendiv");
61 $div.height( val(30) );
62 equals($div.height(), 30, "Test set to 30 correctly");
64 equals($div.height(), 30, "Test hidden div");
66 $div.height( val(-1) ); // handle negative numbers by ignoring #1599
67 equals($div.height(), 30, "Test negative height ignored");
68 $div.css("padding", "20px");
69 equals($div.height(), 30, "Test padding specified with pixels");
70 $div.css("border", "2px solid #fff");
71 equals($div.height(), 30, "Test border specified with pixels");
73 $div.css({ display: "", border: "", padding: "", height: "1px" });
75 var blah = jQuery("blah");
76 equals( blah.height( val(10) ), blah, "Make sure that setting a height on an empty set returns the set." );
79 test("height()", function() {
83 test("width() with function", function() {
87 test("height() with function args", function() {
90 var $div = jQuery("#nothiddendiv");
91 $div.height( 30 ).height(function(i, height) {
92 equals( height, 30, "Make sure previous value is corrrect." );
96 equals( $div.height(), 31, "Make sure value was modified correctly." );
99 test("innerWidth()", function() {
102 var $div = jQuery("#nothiddendiv");
106 border: "2px solid #fff",
110 equals($div.innerWidth(), 30, "Test with margin and border");
111 $div.css("padding", "20px");
112 equals($div.innerWidth(), 70, "Test with margin, border and padding");
114 equals($div.innerWidth(), 70, "Test hidden div");
117 $div.css({ display: "", border: "", padding: "", width: "", height: "" });
120 test("innerHeight()", function() {
123 var $div = jQuery("#nothiddendiv");
127 border: "2px solid #fff",
131 equals($div.innerHeight(), 30, "Test with margin and border");
132 $div.css("padding", "20px");
133 equals($div.innerHeight(), 70, "Test with margin, border and padding");
135 equals($div.innerHeight(), 70, "Test hidden div");
138 $div.css({ display: "", border: "", padding: "", width: "", height: "" });
141 test("outerWidth()", function() {
144 var $div = jQuery("#nothiddendiv");
145 $div.css("width", 30);
147 equals($div.outerWidth(), 30, "Test with only width set");
148 $div.css("padding", "20px");
149 equals($div.outerWidth(), 70, "Test with padding");
150 $div.css("border", "2px solid #fff");
151 equals($div.outerWidth(), 74, "Test with padding and border");
152 $div.css("margin", "10px");
153 equals($div.outerWidth(), 74, "Test with padding, border and margin without margin option");
154 $div.css("position", "absolute");
155 equals($div.outerWidth(true), 94, "Test with padding, border and margin with margin option");
157 equals($div.outerWidth(true), 94, "Test hidden div with padding, border and margin with margin option");
160 $div.css({ position: "", display: "", border: "", padding: "", width: "", height: "" });
163 test("outerHeight()", function() {
166 var $div = jQuery("#nothiddendiv");
167 $div.css("height", 30);
169 equals($div.outerHeight(), 30, "Test with only width set");
170 $div.css("padding", "20px");
171 equals($div.outerHeight(), 70, "Test with padding");
172 $div.css("border", "2px solid #fff");
173 equals($div.outerHeight(), 74, "Test with padding and border");
174 $div.css("margin", "10px");
175 equals($div.outerHeight(), 74, "Test with padding, border and margin without margin option");
176 equals($div.outerHeight(true), 94, "Test with padding, border and margin with margin option");
178 equals($div.outerHeight(true), 94, "Test hidden div with padding, border and margin with margin option");
181 $div.css({ display: "", border: "", padding: "", width: "", height: "" });