Bug Tracker

Ticket #9023 (closed bug: invalid)

Opened 3 years ago

Last modified 3 years ago

jQuery.map( { length: 0 } )

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

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

comment:1 Changed 3 years ago by rwaldron

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

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 3 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?

What? length = 0 is a special case?!

Version 2, edited 3 years ago by rkatic (previous) (next) (diff)

comment:3 Changed 3 years ago by rwaldron

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

comment:4 Changed 3 years ago by rkatic

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

comment:5 Changed 3 years ago by rkatic

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

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

comment:6 Changed 3 years ago by rkatic

A real-world example:  http://jsfiddle.net/8aLnP/ (FIXED LINK)

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

comment:7 Changed 3 years ago by timmywil

#9025 is a duplicate of this ticket.

Note: See TracTickets for help on using tickets.