Bug Tracker

Modify

Ticket #997 (closed bug: fixed)

Opened 6 years ago

Last modified 6 years ago

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:
Blocking: Blocked by:

Description

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.

JK

Change History

comment:1 Changed 6 years ago by brandon

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

Fixed in  Revision 1421.

comment:2 Changed 6 years ago by john

Added a test in SVN rev [1536].

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.