Skip to main content

Bug Tracker

Side navigation

#997 closed bug (fixed)

Opened February 24, 2007 07:09AM UTC

Closed February 25, 2007 05:41PM UTC

Last modified June 21, 2007 04:34AM UTC

isFunction returns "true" on A element

Reported by: jeffkretz Owned by:
Priority: undecided Milestone: 1.1.2
Component: core Version: 1.1.1
Keywords: isFunction Cc:
Blocked by: Blocking:

When an A element has an href with "function" as a part of its path, the jQuery.isFunction method returns "true" incorrectly.

isFunction: function( fn ) {
	return !!fn && typeof fn != "string" &&
		typeof fn[0] == "undefined" && /function/i.test( fn + "" );

This is due to the fact that adding an A element to "" returns its href.

As an example, the following code will throw an exception, because the jQuery initializer tests for the item being a function, and tries to fire it as a document.ready:

$('a').each( function() { var a = $(this); } ); 

Sample page showing this error:

Error shows up in IE6, IE7, FF and Opera.


Attachments (0)
Change History (2)

Changed February 25, 2007 05:41PM UTC by brandon comment:1

resolution: → fixed
status: newclosed

Fixed in Revision 1421.

Changed March 16, 2007 12:06AM UTC by john comment:2

Added a test in SVN rev [1536].