Bug Tracker

Modify

Ticket #12130 (closed bug: duplicate)

Opened 21 months ago

Last modified 21 months 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 21 months ago by dmethvin

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

comment:3 Changed 21 months ago by dmethvin

Duplicate of #7260.

comment:4 Changed 21 months ago by dmethvin

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

comment:5 Changed 21 months 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 21 months 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.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.