Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions pages/upgrade-guide/3.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -347,14 +347,24 @@ https://github.com/jquery/jquery/issues/1722
https://github.com/jquery/jquery/issues/2102
https://github.com/jquery/jquery/issues/2736

#### Breaking change and Feature: $.when() inputs and progress notifications
#### Breaking change and Feature: $.when() arguments

The $.when() method now interprets that any input argument with a `.then()` method is a Promise or Deferred compatible object. In previous versions, if a single Deferred was passed as an input argument, `$.when()` would re-use it and return it as the output Deferred. Now, it *always* returns a new Deferred. This allows any type of`then`-able to be passed as input, including native ES6 Promise or Bluebird promises. You can also convert to the output Deferred to an ES6 promise with `Promise.resolve()` where native Promise is supported.
`$.when` now interprets any input argument with a `then` method as a Promise-compatible "[thenable](https://promisesaplus.com/#point-7)". This allows a much broader range of inputs, including native ES6 Promises and Bluebird promises.

Further, a more clear distinction is now recognized between multi-argument calls to `$.when` and single- or no-argument calls.
Multi-argument calls behave similarly to `Promise.all`, aggregating fulfillment values into a fulfillment array (with jQuery-specific enhancements of also aggregating fulfillment contexts and supporting multi-valued fulfillments), or alternatively rejecting with the first rejection value.
Single- and no-argument calls behave similarly to `Promise.resolve`, returning a Deferred that resolves identically to thenable or Promise-like input, or fulfills with its non-Promise input (as appropriate).
As of jQuery 3.0, both of these return a new Deferred (previous versions did not create a new Deferred when called with a single Deferred input).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we make any assertions about the result being sync or async?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think any relevant changes are covered in the Deferred section, especially if jquery/jquery#3105 lands.


https://github.com/jquery/jquery/issues/2018
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these have two spaces after them to create a line break? I can't tell.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I didn't realize why they were present until their removal borked the GitHub rich diff.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah and they call html markup obscure. 😈 Another option would be to put them all on one line but turn them into links, something like Related: gh-1234, gh-2345. That could all be reformatted in a later pass though.

https://github.com/jquery/jquery/issues/2546
https://github.com/jquery/jquery/issues/3029

#### Breaking change: $.when() progress notifications
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Good call on breaking this out


As of jQuery 3.0, the `$.when()` method no longer passes along progress notifications from input Deferreds to the output Deferred. Progress messages are not part of the Promises/A+ specification, and the behavior of progress notifications in `$.when()` were not previously documented in the jQuery API.

https://github.com/jquery/jquery/issues/2710
https://github.com/jquery/jquery/issues/2546


### Dimensions
Expand Down