New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
jQuery.when: unnecessary asynchronous behavior when called with only one argument #4798
Comments
Thanks for the report. The test case is always useful; manually typing code makes the whole process just a bit longer and sometimes this may be enough of a hindrance to postpone looking at the issue. Please prepare a working test case in the future, especially when you already have the code available. I created https://jsbin.com/quyupuq/1/edit?html,js,console where the behavior difference between single-arg & mutli-arg scenarios is viisble. @gibson042 do you know if this is intended? I was looking at past issues but I haven't found anything that would justify this. |
This is at the interplay of a few different issues, including #3000 and #3465 (comment) . At any rate, we would definitely consider a patch that addressed this issue without breaking tests. |
Description
The function "jQuery.when" shows apparently unneccessary asynchronous behavior when called with only one argument.
For example executing the code below
in a javascript console produces the following console output
There really seems to be no reason for the handlers added to the promise returned by the function "jQuery.when" to not be called synchronously while the deferred object (provided as first and only argument to that call of the function "jQuery.when") is being resolved.
When I add any single additional argument (like
undefined
) to that call of the function "jQuery.when"the unnecessary asynchronous behavior disappears and the handlers are called as synchronously as expected.
Link to test case
I was able to reproduce the behavior using the console at https://codepen.io/mgol/pen/wNWJbZ without any problems, thereby I hope no link to a test case will be necessary here.
The text was updated successfully, but these errors were encountered: