Bug Tracker

Opened 11 years ago

Closed 11 years ago

Last modified 5 years ago

#118 closed bug (fixed)

Can't .attr('disabled', false);

Reported by: dave.methvin@… Owned by:
Priority: major Milestone: 1.0
Component: core Version: 1.0
Keywords: Cc:
Blocked by: Blocking:


In SVN 169, it's not possible to set an attribute to boolean false. The problem is in jQuery.fn.attr line 244 & 247:

   return key.constructor != String || value ?
     if ( value == undefined )

Since value is false in these cases it wrongly goes to the "return a value" case. Try this instead:

   return key.constructor != String || value !== undefined ?
     if ( value === undefined )

Also, in jQuery.attr line 1079, I would suggest this enhancement to allow "null" to be interpreted as removeAttribute, which would close bug 102 (http://proj.jquery.com/dev/bugs/bug/102/)

   if ( v === null ) {
      o[a] = undefined;  // can't use delete operator in IE
      if ( o.removeAttribute )
   } else if ( v != undefined ) {
      o[a] = v;
      if ( o.setAttribute  && a != "disabled" )

I see a problem with Firefox 1.5 where a disabled button refuses to go back to gray after you explicitly set disabled=true on the button and then try disabled=false. The problem persists even if you remove the disabled attribute, and Firebug shows the attribute is still there. It looks like the check for "disabled" was intended to work around that, but neither the old or new code fixes it completely. Others have noticed it, seems to be a FF bug: http://www.milonic.com/mfa/2006-June/007562.html and https://bugzilla.mozilla.org/show_bug.cgi?id=149284

Change History (3)

comment:1 Changed 11 years ago by dave.methvin

  • Component changed from ajax to core

comment:2 Changed 11 years ago by john

  • Milestone set to 1.0
  • Version set to 1.0

comment:3 Changed 11 years ago by john

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

This has been resolved in jQuery SVN.

Note: See TracTickets for help on using tickets.