Bug Tracker

Modify

Ticket #5721 (closed bug: worksforme)

Opened 3 years ago

Last modified 15 months ago

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:
Blocking: Blocked by:

Description

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

comment:1 Changed 3 years ago by dmethvin

  • Status changed from new to closed
  • Resolution set to invalid

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).

 http://www.w3schools.com/Xhtml/xhtml_syntax.asp

comment:2 Changed 3 years ago by sirshannon

  • Status changed from closed to reopened
  • Resolution invalid deleted

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 3 years ago by addyosmani

  • Priority changed from major to low
  • Status changed from reopened to closed
  • Resolution set to worksforme

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.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.