Side navigation
#12130 closed bug (duplicate)
Opened July 24, 2012 12:40AM UTC
Closed July 24, 2012 01:09AM UTC
Last modified July 24, 2012 08:20AM UTC
jQuery.each on object with length element.
Reported by: | jakecigar@gmail.com | Owned by: | |
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | unfiled | Version: | 1.7.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
I think jQuery.each should check for length to be present and an integer, rather than just checking for it’s existance.
The innocent Object { "length":"33", "text":"foo" } can’t be used with $.each.
Attachments (0)
Change History (6)
Changed July 24, 2012 12:40AM UTC by comment:1
Changed July 24, 2012 01:09AM UTC by comment:2
resolution: | → duplicate |
---|---|
status: | new → closed |
Changed July 24, 2012 01:10AM UTC by comment:4
Honestly, I think doing this would just confuse things more.
Changed July 24, 2012 01:13AM UTC by comment:5
I realize a 'fix' would not work for everybody. But a new function $.foreach and deprecating $.each might be doable.
We have so many JSON users who could be bitten by this 'bug'
Changed July 24, 2012 08:20AM UTC by comment:6
You said it yourself, a "fix" wouldn't work for everybody. The trick here is that you should probably not use words like "length" or "nodeType" as properties of your object.
It came up on the forum
http://forum.jquery.com/topic/parsejson-gotcha-with-reserved-words#14737000003512366