Bug Tracker

Opened 12 years ago

Closed 12 years ago

#10541 closed enhancement (plugin)

jQuery.map should not flatten out result array.

Reported by: kausikram@… Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.7b2
Keywords: Cc:
Blocked by: Blocking:

Description

jQuery.map has a behaviour of flattening out the result. this behaviour of jQuery.map is highly confusing while working with nested arrays and the work around for it (by making the return of the callback a single item array is hacky to say the least)

it would be helpful if jQuery.map takes an optional argument to override this default behaviour and return a nested array, if this parameter is set.

Example and test cases : http://jsfiddle.net/tNYPQ/

Change History (1)

comment:1 Changed 12 years ago by dmethvin

Resolution: plugin
Status: newclosed

The existing behavior is exactly what we want for our internal use. Although this method is exposed for others to use, we don't want to add features unneeded by core since it adds to complexity, size, and run time. A more featureful implementation could be done as a plugin rather than added to $.map.

Note: See TracTickets for help on using tickets.