Bug Tracker

Opened 13 years ago

Closed 12 years ago

Last modified 11 years ago

#5721 closed bug (worksforme)

Webkit: Radio checked state incorrect when creating an input with a name

Reported by: sirshannon Owned by:
Priority: low Milestone: 1.4
Component: core Version: 1.4a2
Keywords: webkit input radio checked Cc:
Blocked by: Blocking:


In Chrome and Safari, I'm getting an error creating a radio with a checked state:

$('<input type="radio" checked=""/>')[0].checked returns true

$('<input type="radio" checked="" name="foo"/>')[0].checked returns false

Both of the above examples properly return true in FF and IE.

Change History (3)

comment:1 Changed 13 years ago by dmethvin

Resolution: invalid
Status: newclosed

The checked attribute should be set to the value "checked" in the markup; setting it to an empty string isn't consistent across doctypes. When the value is set via jQuery you should use a boolean, e.g., .attr("checked", true).


comment:2 Changed 13 years ago by sirshannon

Resolution: invalid
Status: closedreopened

Regardless of what the doctypes say about the attribute, I would expect the behavior to be consistent in both cases. Whether or not 'checked=""' is valid doesn't change the fact that the first example works, but the second example doesn't. This is a bug.

comment:3 Changed 12 years ago by addyosmani

Priority: majorlow
Resolution: worksforme
Status: reopenedclosed

I just ran your original test case in Chrome and Safari and was able to get the exact same output experienced in FireFox and IE.

Check here: http://jsfiddle.net/Lpdjp/1/

If the originally mentioned issue persists, please feel free to submit a new ticket and we will investigate once again. Closing for now.

Note: See TracTickets for help on using tickets.