Bug Tracker

Ticket #180 (closed bug: fixed)

Opened 2 years ago

Last modified 1 year ago

.constructor == Function is not enough

Reported by: sa.cesare@… Assigned to: anonymous
Type: bug Priority: major
Milestone: 1.0 Component: core
Version: 1.0 Keywords:
Cc: Needs:

Description

constructor sometimes represented as {...},so compare it with "Function" is not enough.Something as simple as typeof(data)=="function" will be suffice.Look at $.get() function for example. I'm using 1.0.1 with IE7 on Vista RC1.By the way,why you're using sometimes typeof() and sometimes .constructor,I suggest to use only one of these for convenience;-)

Attachments

Change History

Changed 2 years ago by joern

  • component changed from ajax to core

".constructor ==" occurs 17 times in the jQuery core, ".constructor == Function" 4 times. I'm not sure in which case this is a problem, but if there is any, it shouldn't be too hard to fix.

Changed 2 years ago by sa.cesare@…

Please,fix it if you can-it's not working in .htc context.

Changed 2 years ago by dave.methvin@…

This explains it a bit: http://blogs.msdn.com/ericlippert/archive/2004/02/04/67525.aspx

The .htc's scripting engine isn't the same as the main page's (and jQuery) scripting engine. Since .constructor basically uses the engines address of the Function object and they are two different engines, the two are not equal. Instead, use typeof(x)=="function" as the original poster said.

Changed 2 years ago by joern

Dave, if I get that right, the blog entry you link to, actually says that the instanceof operator won't work in this case. Anyway, can someone provide a test case for this? That would be a great help to solve this.

Changed 2 years ago by joern

  • status changed from new to closed
  • resolution set to fixed

Fixed in SVN (rev. 341).

Note: See TracTickets for help on using tickets.