Skip to main content

Bug Tracker

Side navigation

#9027 closed bug (invalid)

Opened April 30, 2011 09:51AM UTC

Closed April 30, 2011 05:30PM UTC

Last modified May 02, 2011 12:34AM UTC

jQuery.map( jQuery() ) does not enumerates all method names.

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

Test: http://jsfiddle.net/7jSF8/

Documentation:

"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."

jQuery() has length == 0, and no value at index -1, so by definition it will not be considered array-like!

But strangely if the empty jquery is from an iframe, $.map correctly enumerates all properties: #8995.

Silly? Nooooo

Related tickets: #9023

Attachments (0)
Change History (6)

Changed April 30, 2011 10:10AM UTC by rkatic comment:1

Irony at side. Will not fill any further related ticket, I promise, but please reconsider this new crazy feature, even if it was voted by 1E3 persons.

Changed April 30, 2011 05:30PM UTC by timmywil comment:2

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

That is the correct behavior. map iterates through elements, not the prototype. There may be some debate on the related tickets, but this one needs to stay the way it is.

Changed April 30, 2011 06:31PM UTC by rkatic comment:3

@timmywil: Of course this is expected behavior. The point of this ticket is to show how silly that rule is. jQuery objects and arrays are save from this rule, but others are not:

Changed April 30, 2011 07:29PM UTC by timmywil comment:4

Understood, #8995 presents a possible bug. Please do not open tickets to make points.

Changed April 30, 2011 07:36PM UTC by rkatic comment:5

Actually also #9023 and #8993 should be valid. Or at least having a valid point.

Changed May 02, 2011 12:34AM UTC by dmethvin comment:6

jQuery core does not have a need for this corner case to work as described, so this enhancement seems unnecessary.