Bug 14268 - REGRESSION: Radio buttons don't stay selected due to unclosed <label> tags
Summary: REGRESSION: Radio buttons don't stay selected due to unclosed <label> tags
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: 523.x (Safari 3)
Hardware: Mac OS X 10.4
: P1 Normal
Assignee: Nobody
URL: https://www.godaddy.com/gdshop/hostin...
Keywords: HasReduction, InRadar, Regression
Depends on:
Blocks:
 
Reported: 2007-06-20 23:43 PDT by Steven Riggins
Modified: 2007-08-08 22:24 PDT (History)
5 users (show)

See Also:


Attachments
A simpler html example (1.24 KB, text/html)
2007-06-21 00:38 PDT, Steven Riggins
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Steven Riggins 2007-06-20 23:43:28 PDT
Godaddy.com has some javascript or something that makes it auto select the first radio button of any group, no matter which you select.
Comment 1 Steven Riggins 2007-06-21 00:33:36 PDT
Seems to be the missing </label> tags.

Here is a simpler example:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">

<html lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<title>untitled</title>
	<meta name="generator" content="TextMate http://macromates.com/">
	<meta name="author" content="Steven W Riggins">
	<!-- Date: 2007-06-20 -->
</head>
<body>
	<form  style="margin: 0px;" name="frmMain" id="frmMain" method="post" action="https://www.godaddy.com/gdshop/hosting/build.asp?display=virtual">
	<!-- <input type="hidden" name="ci" value="1480">
	<input type="hidden" name="byos" value=""> -->

		<div style="padding-left:10px;">
							<input  type="radio" name="chkPlan" id="economy_1" value="economy_1"><label for="economy_1">&nbsp;&nbsp;1 month, <b>just $29.99/mo</b>

							<input  type="radio" name="chkPlan" id="economy_6" value="economy_6"><label for="economy_6">&nbsp;&nbsp;6 months, <b>just $29.99/mo</b>

							<input  type="radio" name="chkPlan" id="economy_12" value="economy_12"><label for="economy_12">12 months,<b> just $25.49/mo</b>
							<b class="red">SAVE 15%</b>
							<input  type="radio" name="chkPlan" id="economy_24" value="economy_24"><label for="economy_24">24 months,<b> just $23.99/mo</b>
							<b class="red">SAVE 20%</b>
		</div>

	</form>

</body>
</html>

Comment 2 Steven Riggins 2007-06-21 00:38:39 PDT
Created attachment 15157 [details]
A simpler html example
Comment 3 David Kilzer (:ddkilzer) 2007-06-21 07:50:10 PDT
(In reply to comment #1)
> Seems to be the missing </label> tags.

Confirmed, the unclosed <label> tags are nesting on Safari 3.0 (522.11) on Mac OS X 10.4.10 (8R218).

Marking as a regression since hitting just the radio buttons (not the label text) in Safari 3.0 (522.11) is broken compared to  Safari 2.0.4 (419.3).

You may see the behavior in Hixie's Live DOM Viewer:

http://software.hixie.ch/utilities/js/live-dom-viewer/

On Firefox 2.0.0.4, the unclosed <label> tags are closed when another <label> tag is encountered.  I'm not sure if this strategy will work on WebKit since the radio buttons themselves appear to be responding to the <label> tags as well.
Comment 4 David Kilzer (:ddkilzer) 2007-06-21 17:13:15 PDT
<rdar://problem/5286443>
Comment 5 Beth Dakin 2007-07-23 11:51:44 PDT
Interestingly, the reduction does not behave correctly in Firefox either. The failure doesn't seem quite as spectacular as it is in Safari, though.
Comment 6 Beth Dakin 2007-08-07 14:31:09 PDT
The spec (http://www.w3.org/TR/html4/interact/forms.html#h-17.9) indicates that a closing tag is required. Firefox also behaves strangely with this test case, but their behavior actually seems the best way to error-handle this given the description in the spec.
Comment 7 Beth Dakin 2007-08-07 14:34:15 PDT
Actually, Firefox still seems wrong.
Comment 8 Beth Dakin 2007-08-07 15:03:50 PDT
Firefox behaves "correctly" when you click the label text. ("Correctly" means that the button you would expect to be selected is selected.) It behaves "incorrectly" when you click the actual radio button. WinIE behaves "correctly" in both cases/
Comment 9 Beth Dakin 2007-08-07 15:52:28 PDT
I have done a bit of testing, and it looks like IE might close the <label> tag right after the text content if the <label> has a for attribute. Without a for attribute, it looks like they close the <label> when a new <label> is encountered. This behavior makes sense to me, and seems to make sense in the context of the spec too.
Comment 10 Ian 'Hixie' Hickson 2007-08-07 18:27:22 PDT
Using the Live DOM Viewer I was unable to detect any difference in WinIE with respect to closing of <label> elements with or without for="" attributes. Indeed it seems to nest <label> elements happily regardless of what is going on.
Comment 12 Beth Dakin 2007-08-07 22:33:57 PDT
Indeed! I vow hereafter to use Hixie's DOM viewer before poking about with bunches of test cases and coming to faulty conclusions. /me repeats 100 times on the chalkboard. 
Comment 13 Beth Dakin 2007-08-08 22:24:40 PDT
I fixed this with r24953.