Bug Tracker

Opened 8 years ago

Closed 8 years ago

#9446 closed bug (fixed)

Chained Deferred.pipe functions don't keep the original context from Deferred.resolveWith

Reported by: exogen@… Owned by: jaubourg
Priority: low Milestone: 1.next
Component: deferred Version: 1.6.1
Keywords: Cc:
Blocked by: Blocking:

Description

If I chain multiple pipes and use resolveWith like so...

var defer = $.Deferred();
var promise = defer.pipe(function(x) {
    // `this` will be `obj`
    return x * 2;
}).pipe(function(x) {
    // `this` will be `defer`?
    return x - 1;
});
defer.resolveWith(obj, [5]);

...the first pipe function will get this set to obj as I expect, but the next function in the chain will get its context set back to the Deferred object. I would expect the context to be passed along the chain, so that the second pipe function also gets this set to obj.

Change History (3)

comment:1 Changed 8 years ago by addyosmani

Cc: jauborg added
Component: unfiledajax
Priority: undecidedlow

comment:2 Changed 8 years ago by timmywil

Cc: jauborg removed
Component: ajaxdeferred
Owner: set to jaubourg
Status: newassigned

comment:3 Changed 8 years ago by jaubourg

Resolution: fixed
Status: assignedclosed

Fixes #9446. Context is properly propagated using pipe. If context was the original deferred, then context is updated to next deferred in the chain. Unit tests added.

Changeset: 139135a98aab1c422e5ae05b026535a40d58328f

Note: See TracTickets for help on using tickets.