Bug Tracker

Opened 12 years ago

Closed 11 years ago

Last modified 11 years ago

#3255 closed bug (fixed)

$().attr does not work popperly with type

Reported by: Licenser Owned by: flesler
Priority: major Milestone: 1.3
Component: core Version: 1.2.6
Keywords: exception type input Cc: Licenser
Blocked by: Blocking:

Description

When creating a new html element via $() using .attr() to set the type of the input causes a expection that type can't be changed.

var checkbox = $('<input/>');
checkbox.attr('type', 'checkbox'); // => exception

a workaround is:

var checkbox = $('<input type="checkbox"/>');

Attachments (3)

3255.html (513 bytes) - added by nathanhammond 12 years ago.
Test Case
clean[5831].diff (294 bytes) - added by flesler 12 years ago.
For some reason it makes a test fail.. but seems like a feasible solution
clean[5831].v2.diff (1.0 KB) - added by flesler 12 years ago.
Alternate solution, no test fail, don't ask why!!!

Download all attachments as: .zip

Change History (7)

comment:1 Changed 12 years ago by nathanhammon

The fix for this will probably appear in jQuery.clean(). Once appending the HTML string to that temporary div, parentNode will no longer return undefined and the throw will be executed:

if ( name == "type" && jQuery.nodeName( elem, "input" ) && elem.parentNode ) {
    throw "type property can't be changed";

Changed 12 years ago by nathanhammond

Attachment: 3255.html added

Test Case

comment:2 Changed 12 years ago by flesler

Owner: set to flesler
Status: newassigned

Changed 12 years ago by flesler

Attachment: clean[5831].diff added

For some reason it makes a test fail.. but seems like a feasible solution

Changed 12 years ago by flesler

Attachment: clean[5831].v2.diff added

Alternate solution, no test fail, don't ask why!!!

comment:3 Changed 11 years ago by flesler

Cc: Licenser added
Resolution: fixed
Status: assignedclosed

Fixed at [5999].

comment:4 Changed 11 years ago by john

Landed a comprehensive fix in [6026].

Note: See TracTickets for help on using tickets.