Bug Tracker

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#9023 closed bug (invalid)

jQuery.map( { length: 0 } )

Reported by: rkatic Owned by:
Priority: low Milestone: 1.next
Component: core Version: 1.5.2
Keywords: Cc:
Blocked by: Blocking:

Description

IF

{ length: 3, 0: "a", 1: "b", 2: "c" }

is array-like, then there is NO reason why

{ length: 0 }

should not.

Test: http://jsfiddle.net/Aa8vc/

Change History (7)

comment:1 Changed 5 years ago by rwaldron

  • Component changed from unfiled to core
  • Priority changed from undecided to low
  • Resolution set to invalid
  • Status changed from new to closed

Consider the following:

Array-like objects, such as jQuery collections, are treated as arrays. In other words, if an object has a .length property and a value on the .length - 1 index, it is traversed as an array.

From http://api.jquery.com/jquery.map/

Your example does not meet the criteria and therefore is invalid.

comment:2 Changed 5 years ago by rkatic

Disagree.

"Array-like objects, such as jQuery collections, are treated as arrays. In other words, if an object has a .length property and a value on the .length - 1 index, it is traversed as an array."

So { length: 0, "-1": "a" } is a an array, but { length: 0 } is not?

Last edited 5 years ago by rkatic (previous) (diff)

comment:3 Changed 5 years ago by rwaldron

disagree all you want, I was simply quoting the docs.

comment:4 Changed 5 years ago by rkatic

So, ipse dixit. That's your argument? Holy Docs.

comment:5 Changed 5 years ago by rkatic

Btw. fixing this would also fix #8993, #8995.

Last edited 5 years ago by rkatic (previous) (diff)

comment:6 Changed 5 years ago by rkatic

Version 1, edited 5 years ago by rkatic (previous) (next) (diff)

comment:7 Changed 5 years ago by timmywil

#9025 is a duplicate of this ticket.

Note: See TracTickets for help on using tickets.