Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #1095 bug where radio buttons became unchecked during show(). A…

…lso added unit test and had to fix a selector test that was broken by the new testing div in test/index.html. Last made some whitespace changes.
  • Loading branch information...
commit e2ef3df86d5f54274bf2b779d882c30aa0886bfe 1 parent b9371a6
davidserduke authored November 16, 2007
2  src/core.js
@@ -765,7 +765,7 @@ jQuery.extend({
765 765
 				// Otherwise, we need to flip out more values
766 766
 				} else {
767 767
 					elem = jQuery( elem.cloneNode(true) )
768  
-						.find(":radio").removeAttr("checked").end()
  768
+						.find(":radio").removeAttr("checked").removeAttr("defaultChecked").end()
769 769
 						.css({
770 770
 							visibility: "hidden",
771 771
 							position: "absolute",
25  test/index.html
@@ -132,15 +132,24 @@ <h2 id="userAgent"></h2>
132 132
 			<input type="radio" name="R1" value="2" />
133 133
 			<input type="text" name="My Name" value="me" />
134 134
 			<input type="reset" name="reset" value="NO" />
135  
-			<select name="S1">
				<option value="abc">ABC</option>
				<option value="abc">ABC</option>
				<option value="abc">ABC</option>
			</select>
			<select name="S2" multiple="multiple" size="3">
				<option value="abc">ABC</option>

				<option value="abc">ABC</option>
				<option value="abc">ABC</option>
			</select>
  135
+			<select name="S1">
  136
+				<option value="abc">ABC</option>
  137
+				<option value="abc">ABC</option>
  138
+				<option value="abc">ABC</option>
  139
+			</select>
  140
+			<select name="S2" multiple="multiple" size="3">
  141
+				<option value="abc">ABC</option>
  142
+				<option value="abc">ABC</option>
  143
+				<option value="abc">ABC</option>
  144
+			</select>
136 145
 			<select name="S3">
137 146
 				<option selected="selected">YES</option>
138 147
 			</select>
139 148
 			<select name="S4">
140 149
 				<option value="" selected="selected">NO</option>
141 150
 			</select>
142  
-			<input type="submit"  name="sub1" value="NO" />
143  
-			<input type="submit"  name="sub2" value="NO" />
  151
+			<input type="submit" name="sub1" value="NO" />
  152
+			<input type="submit" name="sub2" value="NO" />
144 153
 			<input type="image" name="sub3" value="NO" src="submit.gif" />
145 154
 			<button name="sub4" type="submit" value="NO">NO</button>
146 155
 			<input name="D1" type="text" value="NO" disabled="disabled" />
@@ -150,6 +159,16 @@ <h2 id="userAgent"></h2>
150 159
 				<option selected="selected" value="NO">NO</option>
151 160
 			</select>
152 161
 		</form>
  162
+		<div id="moretests">
  163
+			<form>
  164
+				<div id="checkedtest" style="display:none;">
  165
+					<input type="radio" name="checkedtestradios" checked="checked"/>
  166
+					<input type="radio" name="checkedtestradios" value="on"/>
  167
+					<input type="checkbox" name="checkedtestcheckboxes" checked="checked"/>
  168
+					<input type="checkbox" name="checkedtestcheckboxes" />
  169
+				</div>
  170
+			</form>
  171
+		</div>
153 172
 	</div>
154 173
 	</dl>
155 174
 	
12  test/unit/core.js
@@ -389,6 +389,18 @@ test("css(String, Object)", function() {
389 389
 	ok( $('#foo').css('opacity') == '1', "Assert opacity is 1 when set to an empty String" );
390 390
 });
391 391
 
  392
+test("jQuery.css(elem, 'height') doesn't clear radio buttons (bug #1095)", function () {
  393
+	expect(4);
  394
+
  395
+	var $checkedtest = $("#checkedtest");
  396
+	// IE6 was clearing "checked" in jQuery.css(elem, "height");
  397
+	jQuery.css($checkedtest[0], "height");
  398
+	ok( !! $(":radio:first", $checkedtest).attr("checked"), "Check first radio still checked." );
  399
+	ok( ! $(":radio:last", $checkedtest).attr("checked"), "Check last radio still NOT checked." );
  400
+	ok( !! $(":checkbox:first", $checkedtest).attr("checked"), "Check first checkbox still checked." );
  401
+	ok( ! $(":checkbox:last", $checkedtest).attr("checked"), "Check last checkbox still NOT checked." );
  402
+});
  403
+
392 404
 test("text()", function() {
393 405
 	expect(1);
394 406
 	var expected = "This link has class=\"blog\": Simon Willison's Weblog";
68  test/unit/fx.js
@@ -12,43 +12,43 @@ test("animate(Hash, Object, Function)", function() {
12 12
 });
13 13
 
14 14
 test("animate option (queue === false)", function () {
15  
-  expect(1);
16  
-  stop();
17  
-  
18  
-  var order = [];
19  
-
20  
-  var $foo = $("#foo");
21  
-  $foo.animate({width:'100px'}, 200, function () {
22  
-    // should finish after unqueued animation so second
23  
-    order.push(2);
24  
-  });
25  
-  $foo.animate({fontSize:'2em'}, {queue:false, duration:10, complete:function () {
26  
-    // short duration and out of queue so should finish first
27  
-    order.push(1);
28  
-  }});
29  
-  $foo.animate({height:'100px'}, 10, function() {
30  
-    // queued behind the first animation so should finish third 
31  
-    order.push(3);
32  
-    isSet( order, [ 1, 2, 3], "Animations finished in the correct order" );
33  
-    start();
34  
-  });
  15
+	expect(1);
  16
+	stop();
  17
+
  18
+	var order = [];
  19
+
  20
+	var $foo = $("#foo");
  21
+	$foo.animate({width:'100px'}, 200, function () {
  22
+		// should finish after unqueued animation so second
  23
+		order.push(2);
  24
+	});
  25
+	$foo.animate({fontSize:'2em'}, {queue:false, duration:10, complete:function () {
  26
+		// short duration and out of queue so should finish first
  27
+		order.push(1);
  28
+	}});
  29
+	$foo.animate({height:'100px'}, 10, function() {
  30
+		// queued behind the first animation so should finish third 
  31
+		order.push(3);
  32
+		isSet( order, [ 1, 2, 3], "Animations finished in the correct order" );
  33
+		start();
  34
+	});
35 35
 });
36 36
 
37 37
 test("queue() defaults to 'fx' type", function () {
38  
-  expect(2);
39  
-  stop();
40  
-
41  
-  var $foo = $("#foo");
42  
-  $foo.queue("fx", [ "sample", "array" ]);
43  
-  var arr = $foo.queue();
44  
-  isSet(arr, [ "sample", "array" ], "queue() got an array set with type 'fx'");
45  
-  $foo.queue([ "another", "one" ]);
46  
-  var arr = $foo.queue("fx");
47  
-  isSet(arr, [ "another", "one" ], "queue('fx') got an array set with no type");
48  
-  // clean up after test
49  
-  $foo.queue([]);
50  
-
51  
-  start();
  38
+	expect(2);
  39
+	stop();
  40
+
  41
+	var $foo = $("#foo");
  42
+	$foo.queue("fx", [ "sample", "array" ]);
  43
+	var arr = $foo.queue();
  44
+	isSet(arr, [ "sample", "array" ], "queue() got an array set with type 'fx'");
  45
+	$foo.queue([ "another", "one" ]);
  46
+	var arr = $foo.queue("fx");
  47
+	isSet(arr, [ "another", "one" ], "queue('fx') got an array set with no type");
  48
+	// clean up after test
  49
+	$foo.queue([]);
  50
+
  51
+	start();
52 52
 });
53 53
 
54 54
 test("stop()", function() {
6  test/unit/selector.js
@@ -59,8 +59,8 @@ test("id", function() {
59 59
 	t( "Child escaped ID", "form > #foo\\:bar", ["foo:bar"] );
60 60
 	t( "Child escaped ID", "form > #test\\.foo\\[5\\]bar", ["test.foo[5]bar"] );
61 61
 	
62  
-	t( "ID Selector, child ID present", "#form > #radio1", ["radio1"] );  // bug #267
63  
-	t( "ID Selector, not an ancestor ID", "#form  #first", [] );
  62
+	t( "ID Selector, child ID present", "#form > #radio1", ["radio1"] ); // bug #267
  63
+	t( "ID Selector, not an ancestor ID", "#form #first", [] );
64 64
 	t( "ID Selector, not a child ID", "#form > #option1a", [] );
65 65
 	
66 66
 	t( "All Children of ID", "#foo > *", ["sndp", "en", "sap"] );
@@ -193,7 +193,7 @@ test("pseudo (:) selectors", function() {
193 193
 	t( "Selected Option Element", "#form option:selected", ["option1a","option2d","option3b","option3c"] );
194 194
 	t( "Text Contains", "a:contains('Google')", ["google","groups"] );
195 195
 	t( "Text Contains", "a:contains('Google Groups')", ["groups"] );
196  
-	t( "Element Preceded By", "p ~ div", ["foo","fx-queue","fx-tests"] );
  196
+	t( "Element Preceded By", "p ~ div", ["foo","fx-queue","fx-tests", "moretests"] );
197 197
 	t( "Not", "a.blog:not(.link)", ["mark"] );
198 198
 	
199 199
 	t( "nth Element", "p:nth(1)", ["ap"] );

0 notes on commit e2ef3df

Please sign in to comment.
Something went wrong with that request. Please try again.