On Apr 25, 7:18 am, Erem <[email protected]> wrote:
> Hey guys,
>
> I observed some unexplainable behavior in GWTTestCase today. Has
> anyone else seen this? If not I'll go ahead and file an issue.
>
> The problem:
> Any GWT/JSNI-created Javascript Array that I pass to functions defined
> in an external .js library will return FALSE for "instanceof Array".

Because GWT code runs in an iframe, the Array object (and prototype of
any array created within the iframe) is not the same as $wnd.Array.
In other words, "instanceof" won't work cross-frame; this is a known
JS flaw. In browsers following the ECMAScript specification to the
letter, it's possible to implement an "isArray" function as:
Object.prototype.toString.call(o) === '[object Array]', only if the
toString methods hasn't been overwritten of course!

See:
http://perfectionkills.com/instanceof-considered-harmful-or-how-to-write-a-robust-isarray/

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to