Skip to main content

Bug Tracker

Side navigation

#14409 closed bug (notabug)

Opened September 30, 2013 11:28PM UTC

Closed October 01, 2013 12:49AM UTC

.map(fn).toArray() and .map(fn).get() will flatten inner arrays

Reported by: nick@clearstorydata.com Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.9.1
Keywords: Cc:
Blocked by: Blocking:
Description

Mapping over a selection with a function that returns arrays will flatten all returned values into a 1d array, instead of returning a 2d array as expected.

To reproduce:

$('<p/>').map(function() { return [1,2]; }).get(); // [1,2]
$('<p/><p/>').map(function() { return [1,2]; }).get(); // [1,2,1,2]
Attachments (0)
Change History (1)

Changed October 01, 2013 12:49AM UTC by dmethvin comment:1

resolution: → notabug
status: newclosed
instead of returning a 2d array as expected.

Was that expected after reading the docs?

The function can return an individual data item or an array of data items to be inserted into the resulting set. If an array is returned, the elements inside the array are inserted into the set. -- http://api.jquery.com/map/