That code may not be exactly right (its been a few months, so I’m writing it from memory), but you get the gist. It is recursively looking for all properties of an object that aren’t functions and sticks them into another object, which is then passed to flash.
There also seems to be a bug with all browsers when sending objects from one window to another, then checking “instanceof Function”.
The “instanceof Function” issue is not a bug but, what is in my opinion, a flaw in the ECMA spec. If you pass a function from one window another, then do … “myFunct instanceof window.opener.Function” then it will return true, but just “myFunc instanceof Function” will return false, because “Function” is not in the instance/prototype chain of the “Function” object in the new window.
It’s all very confusing IMHO, but you lets say you have a set of scripts that constitute a little framework. You include it in one window and also in the other, then you create an object that has a prototype of “MyClass”… when you pass it from one window to the other, if you call “myNewObj instanceof MyClass” in both windows, you will get different results. In the child window has a whole different set of classes (even though to you, they are the same and have the same name, the browser treats them as different).
This is a big deal for classes that most assume are “built in”. Classes such as Array, Function, Object are technically new instances in every since window or frame. So an Array created in one window and passed to another will no longer return the correct response for “myArray instanceof Array” in the child window / frame.
I submitted a bugreport to Firefox and they gave me some good info on why it happens and what the spec says: Firefox Buzilla Link
What I found is that when passing an object from one window to another like this:
For the object in the child window, in Internet Explorer “typeof obj["func1"]” returns “object” instead of “function”. In Firefox, Safari, etc it returns “function”.
Some possible solutions:
You must be connected to post a comment.