Bug Tracker

Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#12130 closed bug (duplicate)

jQuery.each on object with length element.

Reported by: [email protected] Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.7.2
Keywords: Cc:
Blocked by: Blocking:


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.

Change History (6)

comment:2 Changed 11 years ago by dmethvin

Resolution: duplicate
Status: newclosed

comment:3 Changed 11 years ago by dmethvin

Duplicate of #7260.

comment:4 Changed 11 years ago by dmethvin

Honestly, I think doing this would just confuse things more.

comment:5 Changed 11 years ago by anonymous

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'

comment:6 Changed 11 years ago by Rick Waldron

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.

Note: See TracTickets for help on using tickets.