Ticket #2152 (closed enhancement: fixed)
Checking object constructors for equality with "Array" function is inaccurate
|Reported by:||davidserduke||Owned by:|
Originally reported by m...@…, Dec 08, 2007
What steps will reproduce the problem?
- Create code on a page that uses a jQuery API whose behavior varies based on whether a parameter is an array
- Create an iframe in that page and load it with another page
- From the other page, use "parent" to invoke the function from step 1 with an array. Note that the function behaves as if the parameter is *not* an array.
What is the expected output? What do you see instead?
A legitimate red-blooded array constructed on a page should be treated as an array by jQuery code called on any other page reachable through the DOM. Things are just weird if it doesn't.
What version of the product are you using? On what operating system?
1.2.1 and the problem occurs on both Firefox and IE.
Please provide any additional information below.
There is a separate instance of the "Array" constructor in the global context ("window") for every page. Thus, checking to see if the "constructor" property of an object is equal to the function referenced by the "global" variable called "Array" will fail for arrays constructed on a different page.
(The same holds true of course for any other built-in type, but Array causes the most problems.)
The use of nested iframes within an application has its adherents and detractors, but it's not improper or "wrong". Seems to me that the framework should either handle the situation properly or else explicitly fail in some direct way.
See http://gutfullofbeer.net/arrays/a.html for an elementary illustration (which does not involve any jQuery code).