Skip to main content

Bug Tracker

Side navigation

#9446 closed bug (fixed)

Opened May 27, 2011 06:19PM UTC

Closed July 01, 2011 12:19AM UTC

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

Reported by: exogen@gmail.com 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) {
    //  will be 
    return x * 2;
}).pipe(function(x) {
    //  will be ?
    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 defer.

Attachments (0)
Change History (3)

Changed May 31, 2011 04:21AM UTC by addyosmani comment:1

cc: → jauborg
component: unfiledajax
priority: undecidedlow

Changed June 05, 2011 02:25AM UTC by timmywil comment:2

cc: jauborg
component: ajaxdeferred
owner: → jaubourg
status: newassigned

Changed July 01, 2011 12:19AM UTC by jaubourg comment:3

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