Skip to main content

Bug Tracker

Side navigation

#2152 closed enhancement (fixed)

Opened January 11, 2008 06:37PM UTC

Closed January 31, 2009 09:17PM UTC

Checking object constructors for equality with "Array" function is inaccurate

Reported by: davidserduke Owned by:
Priority: major Milestone: 1.2.2
Component: core Version: 1.2.1
Keywords: Cc:
Blocked by: Blocking:
Description

Originally reported by m...@io.com, Dec 08, 2007

What steps will reproduce the problem?

1. Create code on a page that uses a jQuery API whose behavior varies based on whether a parameter is an array

2. Create an iframe in that page and load it with another page

3. 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).

Attachments (0)
Change History (1)

Changed January 31, 2009 09:17PM UTC by dmethvin comment:1

resolution: → fixed
status: newclosed

This is fixed in jQuery 1.3 with the new implementation of

jQuery.isArray
.