{"action":"closed","issue":{"url":"https://api.github.com/repos/jquery/jquery/issues/3177","repository_url":"https://api.github.com/repos/jquery/jquery","labels_url":"https://api.github.com/repos/jquery/jquery/issues/3177/labels{/name}","comments_url":"https://api.github.com/repos/jquery/jquery/issues/3177/comments","events_url":"https://api.github.com/repos/jquery/jquery/issues/3177/events","html_url":"https://github.com/jquery/jquery/issues/3177","id":160630274,"number":3177,"title":"Fail callbacks receive wrong argument if deferreds are already rejected when passed to $.when","user":{"login":"hashchange","id":481198,"avatar_url":"https://avatars.githubusercontent.com/u/481198?v=3","gravatar_id":"","url":"https://api.github.com/users/hashchange","html_url":"https://github.com/hashchange","followers_url":"https://api.github.com/users/hashchange/followers","following_url":"https://api.github.com/users/hashchange/following{/other_user}","gists_url":"https://api.github.com/users/hashchange/gists{/gist_id}","starred_url":"https://api.github.com/users/hashchange/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hashchange/subscriptions","organizations_url":"https://api.github.com/users/hashchange/orgs","repos_url":"https://api.github.com/users/hashchange/repos","events_url":"https://api.github.com/users/hashchange/events{/privacy}","received_events_url":"https://api.github.com/users/hashchange/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-06-16T10:36:03Z","updated_at":"2016-06-16T15:09:35Z","closed_at":"2016-06-16T15:09:35Z","body":"Suppose a number of deferreds are passed to `$.when`, and these deferreds are, or will be, rejected. If a fail callback is added to `$.when`, it should receive the argument which had been passed to the first failed deferred.\r\n\r\nThat's the behaviour in jQuery 2, and that's how it works in jQuery 3 as well, with one exception: \r\n\r\n    var dfd1 = $.Deferred(),\r\n        dfd2 = $.Deferred();\r\n\r\n    // $.when is set up before the deferreds are rejected: \r\n    // works as expected\r\n    $.when( dfd1, dfd2 ).fail( function() {\r\n      console.log(arguments);\r\n    } );\r\n\r\n    dfd1.reject( \"argument of failed deferred #1\" );\r\n    dfd2.reject( \"argument of failed deferred #2\" );\r\n\r\n    // $.when is set up after the deferreds are rejected: \r\n    // wrong arg passed to callback (in jQuery 3)\r\n    $.when( dfd1, dfd2 ).fail( function() {\r\n      console.log(arguments);\r\n    } );\r\n\r\nIn jQuery 3, the argument of the _last_ failing deferred is passed to the callback if `$.when` receives the deferreds by the time they are already rejected.\r\n\r\nFor a working example, including a comparison of jQuery 2 and 3, see http://jsbin.com/wuhesi/4/edit?html,js,console"}}
{"actor":{"display_login":"gibson042"}}