Side navigation
#15019 closed bug (notabug)
Opened April 16, 2014 10:55AM UTC
Closed April 17, 2014 08:53PM UTC
$.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: |
Description
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.
Explanation:
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.
Attachments (0)
Change History (1)
Changed April 17, 2014 08:53PM UTC by comment:1
resolution: | → notabug |
---|---|
status: | new → closed |
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.
http://bugs.jquery.com/ticket/12348#comment:3