Skip to main content

Bug Tracker

Side navigation

#10541 closed enhancement (plugin)

Opened October 20, 2011 12:21PM UTC

Closed October 20, 2011 09:28PM UTC

jQuery.map should not flatten out result array.

Reported by: kausikram@gmail.com 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/

Attachments (0)
Change History (1)

Changed October 20, 2011 09:28PM UTC by dmethvin comment:1

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.