Bug Tracker

Opened 9 years ago

Closed 9 years ago

#15019 closed bug (notabug)

$.when.apply expands the returning array if it has only one item

Reported by: davidshen84 Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 2.1.0
Keywords: Cc:
Blocked by: Blocking:


Please see sample code at http://jsfiddle.net/HXhMa/. The sample code is created against v2.1.0, but I found it when using v1.8.x in my own project.


In case 1, the input array has more than one item, the following done will call the callback function with all the resolved promises in an array

In case 2, the input array has only one item, the following done call the callback with the resolved promise as the only argument, but not as an array.

This causes the callback function has to implement different logic to handle different arguments schema.

Change History (1)

comment:1 Changed 9 years ago by dmethvin

Resolution: notabug
Status: newclosed

This has been discussed several times before, but the most important reason it won't change is that there is plenty of code depending on the current behavior. If you always want an array just wrap your input args in an array.


Note: See TracTickets for help on using tickets.