Side navigation
#8104 closed bug (wontfix)
Opened January 31, 2011 07:28PM UTC
Closed July 12, 2011 06:48PM UTC
Problem with objects that have a .length property
Reported by: | eamonn.kearns@so-4pt.net | Owned by: | eamonn.kearns@so-4pt.net |
---|---|---|---|
Priority: | high | Milestone: | 1.next |
Component: | core | Version: | 1.5 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
If you create a class with a .length property and try to bind events to it, jQuery throws an Exception.
http://www.jsfiddle.net/Cg8tf/
The problem exists as a result of the makeArray function, which assumes that if the object has a length property, it is an array.
Attachments (0)
Change History (18)
Changed February 01, 2011 03:04PM UTC by comment:1
component: | unfiled → core |
---|---|
priority: | undecided → low |
resolution: | → worksforme |
status: | new → closed |
Changed February 01, 2011 03:08PM UTC by comment:2
Yes, you missed it. Uncomment the declaration of the "this.length = 0" and it stops working, as per the comment directly above the commented out "this.length = 0".
I can even post the lines of code that cause this problem to exist at all, if you like.
Changed February 02, 2011 02:41AM UTC by comment:3
milestone: | 1.next → 1.5.1 |
---|---|
priority: | low → high |
resolution: | worksforme |
status: | closed → reopened |
Less convoluted test case
As noted by the reporter, the problem lies in the .makeArray
function.
Changed February 02, 2011 02:41AM UTC by comment:4
status: | reopened → open |
---|
Changed February 02, 2011 02:51AM UTC by comment:5
I fiddled around with potential solutions.
typeof gives "object" on arrays, so that won't work, but using the .constructor property seems to.
Now, I haven't tested this in either Safari or IE, but it works in both Firefox and Chrome (which leads me to suspect it will work in Safari considering they both use Webkit, so it should also work in Konqueror).
Changed February 02, 2011 06:22PM UTC by comment:6
owner: | → eamonn.kearns@so-4pt.net |
---|---|
status: | open → pending |
Why not use jQuery.type()?
Replying to [comment:5 eamonn.kearns@…]:
I fiddled around with potential solutions. typeof gives "object" on arrays, so that won't work, but using the .constructor property seems to. http://jsfiddle.net/dqqCv/1/ Now, I haven't tested this in either Safari or IE, but it works in both Firefox and Chrome (which leads me to suspect it will work in Safari considering they both use Webkit, so it should also work in Konqueror).
Also...
alert-less:
Changed February 02, 2011 11:10PM UTC by comment:7
Replying to [comment:6 rwaldron]:
Also... alert-less: http://www.jsfiddle.net/rwaldron/UJzgM/4/
:-/ ummm.. ok, sorry to have bothered you with my nasty alerts from 1999
Changed February 02, 2011 11:15PM UTC by comment:8
Replying to [comment:6 rwaldron]:
Why not use jQuery.type()?
Because I am not 100% familiar with the API and was offering any potential solution, knowing that if there was a jQuery specific one that you guys would know how to do it.
Changed February 07, 2011 02:57AM UTC by comment:9
status: | pending → open |
---|
Changed February 07, 2011 03:12AM UTC by comment:10
@jitter,
I'm looking forward to seeing how this is handled.
Changed February 07, 2011 03:45AM UTC by comment:11
Replying to [comment:10 rwaldron]:
@jitter, I'm looking forward to seeing how this is handled.
Likewise.
Changed April 02, 2011 12:48AM UTC by comment:12
milestone: | 1.5.1 → 1.next |
---|
Changed April 27, 2011 07:35PM UTC by comment:13
I think this may be the culprit: https://github.com/jquery/jquery/commit/715d1c5a30cc4986018bbf063713f14c34c3e258
Changed April 30, 2011 06:16AM UTC by comment:14
_comment0: | http://forum.jquery.com/topic/jquery-isarraylike-for-consistency#14737000002236285 → 1304144885263452 |
---|---|
_comment1: | A possible solution would be to limit which types are considered array-like in .merge(). These would be: arrays, jQuery objects, nodelists, and arguments. \ \ http://forum.jquery.com/topic/jquery-isarraylike-for-consistency#14737000002236285 → 1304144970047780 |
A possible solution would be to limit which types are considered array-like in .makeArray(). These would be: arrays, jQuery objects, nodelists, and arguments.
http://forum.jquery.com/topic/jquery-isarraylike-for-consistency#14737000002236285
Changed April 30, 2011 01:16PM UTC by comment:15
_comment0: | https://github.com/rkatic/jquery/compare/rkatic:master...%238104 \ \ I thing dropping support for array-like plain objects is not a big deal. \ It is not used internally. Not sure for the rest of the world. → 1304169642413919 |
---|---|
_comment1: | https://github.com/rkatic/jquery/compare/rkatic:master...%238104 \ \ I thing dropping support for array-like plain objects is not a big deal. \ It is not used internally. Not sure for the rest of the world. \ \ Personally, I am not in favor of fixing this at all. → 1304269412295484 |
https://github.com/rkatic/jquery/compare/rkatic:master...%238104
I thing dropping support for array-like plain objects is not a big deal.
It is not used internally. Not sure for the rest of the world.
Personally, I am not in favor of fixing this at all. But if needed...
Changed May 03, 2011 02:43AM UTC by comment:16
After more testing, I realized that my patch fails with arguments objects.
So ignore it.
Changed May 03, 2011 11:56PM UTC by comment:17
I made some fixes to the patch. It's again available if wanted:
https://github.com/rkatic/jquery/compare/rkatic:master...%238104
Changed July 12, 2011 06:48PM UTC by comment:18
resolution: | → wontfix |
---|---|
status: | open → closed |
Alright, we're not going to pursue this then.
Tested in IE6-7-8, Firefox 3.6.12 - 4b10, Opera 9.x 10.x, Chrome latest and Safari 5
Did I miss the one you're getting errors in?
http://www.jsfiddle.net/rwaldron/Cg8tf/4/