Bug Tracker

Opened 14 years ago

Closed 14 years ago

Last modified 13 years ago

#180 closed bug (fixed)

.constructor == Function is not enough

Reported by: sa.cesare@… Owned by:
Priority: major Milestone: 1.0
Component: core Version: 1.0
Keywords: Cc:
Blocked by: Blocking:

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;-)

Change History (5)

comment:1 Changed 14 years ago by joern

Component: ajaxcore

".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.

comment:2 Changed 14 years ago by sa.cesare@…

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

comment:3 Changed 14 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.

comment:4 Changed 14 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.

comment:5 Changed 14 years ago by joern

Resolution: fixed
Status: newclosed

Fixed in SVN (rev. 341).

Note: See TracTickets for help on using tickets.