Bug Tracker

Modify

Ticket #10541 (closed enhancement: plugin)

Opened 3 years ago

Last modified 3 years ago

jQuery.map should not flatten out result array.

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

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

comment:1 Changed 3 years ago by dmethvin

  • Status changed from new to closed
  • Resolution set to plugin

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.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.