Yes Daniel ... ( sorry I had another ticket open and I read Ariel ... )

On Mon, Jul 27, 2009 at 5:43 PM, Andrea Giammarchi <
andrea.giammar...@gmail.com> wrote:

> Yes Ariel, I was talking about user defined stuff and obviously typeof
> "unknown" breaks the rule as well but this is not the case, is it?
>
> If toString.call(obj) is not reliable cause it could return [object Object]
> DBJ "mess" is not reliable as well because passed variable could not produce
> what he is expecting, starting from document.getElementById which is object
> and not function in IE, got the point?
>
> At least you told me why there is a call rather than an instanceof but what
> about this for IE DOM functions?
>
> return !!obj && typeof obj.toString === "undefined" &&
> /^\s*\bfunction\b/.test(obj);
>
> it works fine to me in every IE (other browsers will be filtered by first
> feature test)
>
> Regards
>
> On Mon, Jul 27, 2009 at 5:29 PM, Daniel Friesen <nadir.seen.f...@gmail.com
> > wrote:
>
>>
>> typeof fn === 'function'; // Some things like
>> document.createElement('object'); return wonky results
>> fn instanceof Function; // Breaks across iFrames
>> toString.call(fn) === "[object Function]"; // Works the same across
>> iFrames and returns more reliable results
>>
>> ~Daniel Friesen (Dantman, Nadir-Seen-Fire) [http://daniel.friesen.name]
>>
>> Andrea Giammarchi wrote:
>> > About isFunction
>> >
>> > I lost the point where toString.call(obj) === "[object Function]" was
>> > introduced instead of obj instanceof function
>> >
>> > I understand differences in IE so I wonder if two distinct callbacks
>> > could solve the odyssey:
>> >
>> >     isFunction: function( obj ) {
>> >         return obj instanceof Function;
>> >     },
>> >
>> >     isDOMFunction: toString.call(window.alert) === "[object Function]" ?
>> >         function( obj ) {
>> >             return toString.call(obj) === "[object Function]";
>> >         }:
>> >         // IE only and only until standard native function manifest
>> >         function( obj ){
>> >             return !!obj && typeof obj.toString === "undefined" &&
>> > /^\s*\bfunction\b/.test(obj);
>> >         }
>> >     ,
>> >
>> > In this way we could consider that in every browser, and when
>> > call/apply are supported, isFunction(fn) will guarantee call/apply
>> > while a DOMFunction could require a try catch or a different behavior
>> > for IE
>> >
>> > switch(true){
>> >     case $.isFunction(fn): return fn.call(what, ever);
>> >     case $.isDOMFunction(fn): what.push.call(what, toArray(fn(ever)));
>> > return what;
>> >     default: throw new Error("what tf?");
>> > }
>> >
>> > ... or maybe not?
>> > Regards
>> >
>> >
>> >
>> > On Sun, Jul 26, 2009 at 4:09 PM, Andrea Giammarchi
>> > <andrea.giammar...@gmail.com <mailto:andrea.giammar...@gmail.com>>
>> wrote:
>> >
>> >     I usually encapsulate toString from Object.prototype and if
>> >     somebody breaks the rule it means we cannot trust anything
>> >     included typeof. So, in few words, nobody has intersts into break
>> >     this rule, imho.
>> >
>> >>     On Jul 26, 2009 8:07 AM, "DBJDBJ" <dbj...@gmail.com
>> >>     <mailto:dbj...@gmail.com>> wrote:
>> >>
>> >>
>> >>     Also, IMHO this yields high level of encapsulation of an important
>> >>     mechanism.
>> >>     Which is a good thing.
>> >>     And it is a fraction of a micro second slower then
>> >>
>> >>     Object.prototype.toString.call(x) === "[object Object]"
>> >>
>> >>     but it is more compact ...
>> >>
>> >>     In any case we are entering the subjective judgement phase, so I
>> >>     think
>> >>     we should stop here and leave it to jQuery team to use this or
>> not...
>> >>
>> >>     --DBJ On Jul 26, 12:09 am, Andrea Giammarchi
>> >>     <andrea.giammar...@gmail.com
>> >>     <mailto:andrea.giammar...@gmail.com>> wrote:
>> >>
>> >>     > I miss the point about regexp usage ... please tell me the
>> >>     difference (in a > real scenario) betwe...
>> >>
>> >>     > On Sat, Jul 25, 2009 at 1:38 PM, DBJDBJ <dbj...@gmail.com
>> >>     <mailto:dbj...@gmail.com>> wrote: > > > This indeed woks :
>>  functi...
>> >>
>> >
>> >
>> > >
>>
>> >>
>>
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to jquery-dev@googlegroups.com
To unsubscribe from this group, send email to 
jquery-dev+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to