Bug Tracker

Ticket #11405 (closed bug: fixed)

Opened 4 years ago

Last modified 3 years ago

deferred.notify() invokes progressCallbacks with deferred as context

Reported by: fastfasterfastest Owned by: jaubourg
Priority: high Milestone: 1.9
Component: deferred Version: 1.7.1
Keywords: Cc: jaubourg
Blocking: Blocked by:


 http://api.jquery.com/deferred.promise states: "The deferred.promise() method allows an asynchronous function to prevent other code from interfering with the progress or status of its internal request"

However, deferred.notify() invokes progressCallbacks with the deferred as the context, allowing other code to interfere with the progress or status of the internal request of the deferred object.

 http://jsfiddle.net/d92Rp/1/ shows how a progress callback is able to reject a deferred.

Arguably, it would make more sense to invoke the progressCallbacks with the promise of the deferred (deferred.promise()) as the context.

The same perhaps/probably applies to deferred.resolve() and deferred.reject(), although in those cases any calls by the done or fail callbacks to resolve or reject would have no effect.

Change History

comment:1 Changed 4 years ago by addyosmani

  • Cc jaubourg added
  • Priority changed from undecided to low
  • Component changed from unfiled to ajax

comment:2 Changed 3 years ago by fastfasterfastest

"Component" should probably be "deferred" (as opposed to "ajax")

comment:3 Changed 3 years ago by rwaldron

  • Owner set to jaubourg
  • Status changed from new to assigned

comment:4 Changed 3 years ago by jaubourg

  • Component changed from ajax to deferred

comment:5 Changed 3 years ago by gibson042

  • Priority changed from low to high
  • Milestone changed from None to 1.9

comment:6 Changed 3 years ago by jaubourg

  • Status changed from assigned to closed
  • Resolution set to fixed

Deferred: .resolve(), .reject() and .notify() now set the callback context to the promise instance rather than the deferred instance ; .then() has also been amended. Fixes #11405.

Changeset: 23d7cf0488bfeaab51d8f55435cab01f5cf990ca

Note: See TracTickets for help on using tickets.