Skip to main content

Bug Tracker

Side navigation

#118 closed bug (fixed)

Opened August 03, 2006 05:35PM UTC

Closed August 15, 2006 04:46AM UTC

Last modified March 15, 2012 06:12PM UTC

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

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

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 )
         o.removeAttribute(a);
   } else if ( v != undefined ) {
      o[a] = v;
      if ( o.setAttribute  && a != "disabled" )
         o.setAttribute(a,v);
   }

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

Attachments (0)
Change History (3)

Changed August 03, 2006 05:35PM UTC by dave.methvin comment:1

component: ajaxcore

Changed August 06, 2006 07:18PM UTC by john comment:2

milestone: → 1.0
version: → 1.0

Changed August 15, 2006 04:46AM UTC by john comment:3

resolution: → fixed
status: newclosed

This has been resolved in jQuery SVN.