Ticket #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: | ||
| Blocking: | Blocked by: |
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
comment:1 Changed 2 years ago by addyosmani
- Cc jauborg added
- Priority changed from undecided to low
- Component changed from unfiled to ajax
comment:2 Changed 2 years ago by timmywil
- Cc jauborg removed
- Owner set to jaubourg
- Status changed from new to assigned
- Component changed from ajax to deferred
comment:3 Changed 23 months ago by jaubourg
- Status changed from assigned to closed
- Resolution set to fixed
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
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.
