jQuery relies on function decompile, won't work on Opera mobile
Monday, January 14, 2008 5:53:41 PM
Here's the code, complete with a frustrated comment from John Resig himself:
// This may seem like some crazy code, but trust me when I say that this
// is the only cross-browser way to do this. --John
isFunction: function( fn ) {
return !!fn && typeof fn != "string" && !fn.nodeName &&
fn.constructor != Array && /function/i.test( fn + "" );
}
John, I feel your pain and that code clearly took quite some effort and testing across various browsers passing in various types of objects - IE collections allowing ()-reference, anyone? It wouldn't surprise me if Opera is one of the culprits that caused you problems here since we try to support some of IE's weirdness and hence "typeof" sometimes returns 'function' when you'd expect it not to.
So I'm sorry to break it to you, but /function/i.test( fn + "" ) won't do what you think on Opera's mobile versions, causing really-hard-to-track-down bugs.
May I suggest adding the below workaround somewhere?
if( (function(){}).toString().match(/\^[ecmascript/i) ) Function.prototype.toString = function(){return 'function'};
Should be all you need..









James Justin HarrellHeroreV # Monday, January 14, 2008 10:44:55 PM
If this has been causing so many problems, why not have it return something like:
function () { [function 1234567] }
Where the number is unique? That would be fast and satisfy most of the uses I've heard of.
Hallvord R. M. Steenhallvors # Tuesday, January 15, 2008 2:57:00 AM
The unique string suggestion is useful. I think we should do that for mobile. (off to update the bugs..)
Olly Hodgsonthinkdrastic # Tuesday, January 15, 2008 10:36:15 AM
http://dev.jquery.com/
Andrew Gregory # Tuesday, January 15, 2008 12:02:34 PM
Hallvord R. M. Steenhallvors # Wednesday, January 16, 2008 3:19:48 PM
artyname # Thursday, January 17, 2008 12:25:14 PM
function (arg1, arg2, arg3...) { [function 1234567] }
_Grey_ # Friday, January 18, 2008 6:17:01 PM
I personally would replace the COM methods in IE in this case, with real ecmascript functions (wrapped around the native "objects"). I'm not sure if this is in line with JQuery policies though...
Anonymous # Tuesday, January 13, 2009 2:22:40 AM
Haavardhaavard # Tuesday, January 27, 2009 3:57:16 PM