Skip to main content

Bug Tracker

Side navigation

#9023 closed bug (invalid)

Opened April 30, 2011 12:45AM UTC

Closed April 30, 2011 01:17AM UTC

Last modified April 30, 2011 07:54PM UTC

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/

Attachments (0)
Change History (7)

Changed April 30, 2011 01:17AM UTC by rwaldron comment:1

component: unfiledcore
priority: undecidedlow
resolution: → invalid
status: newclosed

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.

Changed April 30, 2011 01:28AM UTC by rkatic comment:2

_comment0: 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? \ \ What? length = 0 is a special case?! \ \ 1304188601872351
_comment1: 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 } not? \ \ What? length = 0 is a special case?! \ \ 1304188626800188
_comment2: 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?! \ \ 1304189398900547

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?

Changed April 30, 2011 01:32AM UTC by rwaldron comment:3

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

Changed April 30, 2011 01:35AM UTC by rkatic comment:4

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

Changed April 30, 2011 03:00AM UTC by rkatic comment:5

_comment0: Btw. fixing this would fix http://bugs.jquery.com/ticket/8995 too.1304133005262605
_comment1: Btw. fixing this would fix #8995 too.1304188799863097
_comment2: Btw. fixing this would fix #8993, #8995 too.1304188881027025
_comment3: Btw. fixing this would also fix #8993, #8995, #9025.1304384716955207

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

Changed April 30, 2011 09:27AM UTC by rkatic comment:6

_comment0: Another "not valid" test: http://bugs.jquery.com/ticket/90231304155831408170
_comment1: A real-world example: http://bugs.jquery.com/ticket/90231304189594998882

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

Changed April 30, 2011 07:54PM UTC by timmywil comment:7

#9025 is a duplicate of this ticket.