Bug Tracker

Opened 8 years ago

Closed 8 years ago

#5612 closed bug (fixed)

No way to set attribute that matches a $.fn function name

Reported by: jesse Owned by:
Priority: major Milestone: 1.4
Component: core Version: 1.4a1
Keywords: Cc:
Blocked by: Blocking:


I discovered using the autocomplete plugin with jQuery 1.4a1 that it goes into a recursive infinite loop upon initialization. The cause was this line:

$(input).attr('autocomplete', 'off')

Since $.fn.autocomplete exists, this line actually calls $(input).autocomplete('off') for some reason. It seems the only way to set the 'autocomplete' attribute is with this workaround:

$(input).each(function(){ this.autocomplete = 'off' });

The new code that causes this problem is in jQuery.attr:

if ( name in jQuery.fn && name !== "attr" ) {

return jQuery(elem)[name](value);


Perhaps this is expected behaviour, but I can imagine it will cause problem with other plugins that have attribute-matching plugin names.

Change History (3)

comment:1 Changed 8 years ago by jesse

Just discovered this is caused by the new feature for #5234


So maybe this is desired behavior, maybe it's an unconsidered side effect. But I thought I'd bring it up either way.

comment:2 Changed 8 years ago by dmethvin

See also #5611 which ran into this problem with an attribute named "qtip" which matched the plugin name.

I am not clear on what functionality this feature adds, but it definitely seems problematic as-is.

comment:3 Changed 8 years ago by john

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.