#180 closed bug (fixed)
.constructor == Function is not enough
Reported by: | 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 16 years ago by
Component: | ajax → core |
---|
comment:3 Changed 16 years ago by
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 16 years ago by
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.
".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.