do jQuery promises conform Promises/A+

2019-04-30 02:16发布

问题:

I have read this article which is based on famous Domenic Denicola's article. The first one says:

The problem with jQuery’s implementation (up until version 1.9) is that it doesn’t respect the second part of the specification, “This function should return a new promise…”, that is “then” doesn’t return a new promise object when executing one of the handlers (either the fullfillment, the rejection or the progress handler).

I have found these bugs corresponding to this problem:

  • http://bugs.jquery.com/ticket/14510
  • https://github.com/jquery/jquery/issues/1722

My question is: what is the current state of this issue? Both are opened, so the work is still in progress. But, using jquery 2, you can chain promises with .then. So: is still jQuery.Promises implementation broken? Did anything change since version 1.9?

回答1:

Update: As of jQuery 3.0 the answer is yes. jQuery promises are Promises/A+ compatible and can be safely used.


jQuery promises do not currently adhere to the Promises/A+ specification and thus have some issues and Domenic's article is still valid.

That said active work is being done and jQuery promises will finally be Promises/A+ compliant in the next version. It's still work in progress here is the relevant pull request and here. The last bit of work on it was two days ago.

Exciting times indeed.