Modify ↓
Ticket #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: | |
| 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
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.
Note: See
TracTickets for help on using
tickets.

Fixed in Revision 1421.