Bug Tracker

Opened 12 years ago

Closed 11 years ago

#2152 closed enhancement (fixed)

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...@…, 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
  1. Create an iframe in that page and load it with another page
  1. 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).

Change History (1)

comment:1 Changed 11 years ago by dmethvin

Resolution: fixed
Status: newclosed

This is fixed in jQuery 1.3 with the new implementation of jQuery.isArray.

Note: See TracTickets for help on using tickets.