RESOLVED FIXED 14268
REGRESSION: Radio buttons don't stay selected due to unclosed <label> tags
https://bugs.webkit.org/show_bug.cgi?id=14268
Summary REGRESSION: Radio buttons don't stay selected due to unclosed <label> tags
Steven Riggins
Reported 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.
Attachments
A simpler html example (1.24 KB, text/html)
2007-06-21 00:38 PDT, Steven Riggins
no flags
Steven Riggins
Comment 1 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>
Steven Riggins
Comment 2 2007-06-21 00:38:39 PDT
Created attachment 15157 [details] A simpler html example
David Kilzer (:ddkilzer)
Comment 3 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.
David Kilzer (:ddkilzer)
Comment 4 2007-06-21 17:13:15 PDT
Beth Dakin
Comment 5 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.
Beth Dakin
Comment 6 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.
Beth Dakin
Comment 7 2007-08-07 14:34:15 PDT
Actually, Firefox still seems wrong.
Beth Dakin
Comment 8 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/
Beth Dakin
Comment 9 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.
Ian 'Hixie' Hickson
Comment 10 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.
Beth Dakin
Comment 12 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.
Beth Dakin
Comment 13 2007-08-08 22:24:40 PDT
I fixed this with r24953.
Note You need to log in before you can comment on or make changes to this bug.