I wish it was that easy : ) Unfortunately, we can't really account for
all host objects, which are notorious for their incompliance with
specs (e.g. it's well known how some of them have no constructor
property, and others throw error when accessing certain properties).
Hardcoding few methods barely solves the problem.
We could of course check for "apply/call" members on an object, but
guess what - those are undefined as well : )
As far as I remember jQuery calls object's toString, then tests if
result contains "function". That's clever, but unreliable, as any
other object which defines "toString" to return something that
contains "function" will produce falsy results.

- kangax


On Jun 6, 6:08 am, "T.J. Crowder" <[EMAIL PROTECTED]> wrote:
> OMG, I can confirm this, on IE6 anyway.  (Couldn't they get *anything*
> right?  I mean, I know Firefox has its issues, but...  And yes,
> technically a function is an object, but that's no excuse.)
>
> The only workaround that immediately comes to mind is to actually have
> a list of these and compare against them in IE -- e.g.:
>
> isFunction: (function(){
>     if (typeof window.close == "object") {
>         // IE version, works around typeof returning "object" for
> intrinsic functions
>         return function(object) {
>             return (
>                 typeof object == "function"
>                 || object === window.close
>                 || object === document.getElementById
>                 // etc., etc., etc.
>             );
>         };
>     } else {
>         // Non-IE version, expects typeof to work correctly
>         return function(object) {
>             return typeof object == "function";
>         };
>     }
>
> })()
>
> Blech.  The more of this that happens, the more I want a separate file
> that only IE people have to download containing these workarounds...
> --
> T.J. Crowder
> tj / crowder software / com
>
> On Jun 6, 9:27 am, Viktor Kojouharov <[EMAIL PROTECTED]> wrote:
>
> > Here's quite the problem in IE.
>
> > For certain 'native' functions, like window.close, or
> > document.getElementById, typeof for those functions returns on object
> > in IE. Consequently, Object.isFunction will actually return false for
> > those functions.
>
> > Though there's probably little that can be done, I thought you guys
> > should know about it.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to