jQuery relies on function decompile, won't work on Opera mobile
Monday, 14. January 2008, 17:53:41
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..








HeroreV # 14. January 2008, 22:44
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.
hallvors # 15. January 2008, 02:57
The unique string suggestion is useful. I think we should do that for mobile. (off to update the bugs..)
thinkdrastic # 15. January 2008, 10:36
http://dev.jquery.com/
Andrew Gregory # 15. January 2008, 12:02
hallvors # 16. January 2008, 15:19
artyname # 17. January 2008, 12:25
function (arg1, arg2, arg3...) { [function 1234567] }
_Grey_ # 18. January 2008, 18:17
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 # 13. January 2009, 02:22
Opera Mobile doesn't support prototype.js either.
haavard # 27. January 2009, 15:57