Skip to main content

Bug Tracker

Side navigation

#3255 closed bug (fixed)

Opened August 15, 2008 12:02PM UTC

Closed December 25, 2008 07:48PM UTC

Last modified January 03, 2009 12:51AM UTC

$().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:

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 (0.5 KB) - added by nathanhammond August 15, 2008 09:17PM UTC.

    Test Case

  • clean[5831].diff (0.3 KB) - added by flesler August 19, 2008 12:00PM UTC.

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

  • clean[5831].v2.diff (1.0 KB) - added by flesler August 19, 2008 12:06PM UTC.

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

Change History (4)

Changed August 15, 2008 08:49PM UTC by nathanhammon comment:1

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 August 16, 2008 03:06AM UTC by flesler comment:2

owner: → flesler
status: newassigned

Changed December 25, 2008 07:48PM UTC by flesler comment:3

cc: → Licenser
resolution: → fixed
status: assignedclosed

Fixed at [5999].

Changed January 03, 2009 12:51AM UTC by john comment:4

Landed a comprehensive fix in [6026].