Side navigation
#13160 closed bug (fixed)
Opened January 06, 2013 08:53AM UTC
Closed January 08, 2013 03:39PM UTC
Last modified January 08, 2013 06:18PM UTC
Deferred.then doesn't propagete custom context
Reported by: | nanto_vi | Owned by: | jaubourg |
---|---|---|---|
Priority: | blocker | Milestone: | 1.9 |
Component: | deferred | Version: | 1.9b1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
jQuery 1.9b1 changed a context (value of 'this') in piped promises.
- http://jsfiddle.net/8qCkf/1/ (1.8.2)
- http://jsfiddle.net/gUgMJ/1/ (1.9.0pre)
This change affects codes that expect context to be propagated such as:
function ajaxWithRescueFrom404(settings) { return $.ajax(settings).then(null, function (xhr, status) { return (xhr.status === 404) ? $.Deferred().resolveWith(this, ['', status, xhr]) : this; }); } ajaxWithResuceFrom404({ url: ... }).done(function () { // Treat 404 response as same as succeeded response. // Expect that 'this' is a settings object. });
The commit https://github.com/nanto/jquery/commit/cdac527be80fb2c6585ce6f53a83d4a9144fbf4d fixes this problem.
Attachments (0)
Change History (5)
Changed January 06, 2013 12:56PM UTC by comment:1
component: | unfiled → deferred |
---|---|
milestone: | None → 1.9 |
owner: | → jaubourg |
priority: | undecided → blocker |
status: | new → assigned |
Changed January 06, 2013 06:18PM UTC by comment:2
I made a pull request https://github.com/jquery/jquery/pull/1114
Changed January 08, 2013 03:39PM UTC by comment:3
resolution: | → fixed |
---|---|
status: | assigned → closed |
Propagete context of returned deferred object in Deferred.then(). Fixes #13160
Changeset: e7fdda981928befda72b78e9e2b17e33e232a603
Can you make this a full-fledged pull request with unit tests to boot?