Bug Tracker

Opened 16 years ago

Closed 16 years ago

Last modified 16 years ago

#997 closed bug (fixed)

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: http://www.scorpiontechnology.com/sjo/functiontest.html

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


Change History (2)

comment:1 Changed 16 years ago by brandon

Resolution: fixed
Status: newclosed

Fixed in Revision 1421.

comment:2 Changed 16 years ago by john

Added a test in SVN rev [1536].

Note: See TracTickets for help on using tickets.