Bug Tracker

Ticket #118 (closed bug: fixed)

Opened 8 years ago

Last modified 2 years ago

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

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

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

Change History

comment:1 Changed 8 years ago by dave.methvin

  • Component changed from ajax to core

comment:2 Changed 8 years ago by john

  • Version set to 1.0
  • Milestone set to 1.0

comment:3 Changed 8 years ago by john

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

This has been resolved in jQuery SVN.

Note: See TracTickets for help on using tickets.