Bug Tracker

Ticket #12130 (closed bug: duplicate)

Opened 2 years ago

Last modified 2 years ago

jQuery.each on object with length element.

Reported by: jakecigar@… Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.7.2
Keywords: Cc:
Blocking: Blocked by:

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.

Change History

comment:2 Changed 2 years ago by dmethvin

  • Status changed from new to closed
  • Resolution set to duplicate

comment:3 Changed 2 years ago by dmethvin

Duplicate of #7260.

comment:4 Changed 2 years ago by dmethvin

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

comment:5 Changed 2 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 2 years ago by rwaldron

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.