Skip to main content

Bug Tracker

Side navigation

#5612 closed bug (fixed)

Opened December 07, 2009 08:53PM UTC

Closed December 10, 2009 05:29AM UTC

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:
Description

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.

Attachments (0)
Change History (3)

Changed December 07, 2009 09:01PM UTC by jesse comment:1

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

http://dev.jquery.com/ticket/5234

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

Changed December 08, 2009 12:07AM UTC by dmethvin comment:2

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.

Changed December 10, 2009 05:29AM UTC by john comment:3

resolution: → fixed
status: newclosed