Skip to content

Fix signatures of multiple functions #1067

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

Merged
merged 4 commits into from
Nov 22, 2017

Conversation

dratini0
Copy link
Contributor

@dratini0 dratini0 commented Nov 11, 2017

Following #1066, I have found several functions without a return type. I have assigned appropriate types to these. I have additionally figured out the signature of callbacks.callWith, and fixed that as well. The documentation had a mistake in it, it stated that if the argument is not an array, the callbacks will receive a single argument, but this is not true, it is in fact passed as the second argument of apply.

Finally, I have not assigned a return type to jQuery.error, as it never returns therefore has no return type.

I agree to the CLA. Do I need any paperwork? EDIT: Figured it out.

@jsf-clabot
Copy link

jsf-clabot commented Nov 11, 2017

CLA assistant check
All committers have signed the CLA.

<argument name="args" optional="true">
<desc>An argument, or array of arguments, to pass to the callbacks in the list.</desc>
<argument name="args" optional="true" type="Array">
<desc>An array of arguments to pass to the callbacks in the list. If omitted or undefined, no arguments will be passed.</desc>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @dratini0 , thanks for the PR! I don't think this change is correct, though. Looks to me like args can be "Anything" — an argument or array of arguments like the doc originally stated.

args = args || [];
args = [ context, args.slice ? args.slice() : args ];
queue.push( args );

https://github.com/jquery/jquery/blob/3e902a812014e8a6980e08599c4840b1cb969f7c/src/callbacks.js#L208-L210

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Take a look at the output of this fiddle then: https://jsfiddle.net/48Lmdmmf/

I have missed line 208, and assumed this was the intended behaviour. However, now I see that we are looking at a bug in jQuery, not in the documentation. I will put a pull request through shortly for this:

args = [ context, args.slice ? args.slice() : [args] ];

I will also update this PR accordingly.

@gibson042
Copy link
Member

LGTM. @kswedberg?

@kswedberg
Copy link
Member

LGTM, too, @gibson042 . You wanna merge the PR? I would do it, but I can't seem to successfully run grunt deploy with my local setup anymore.

@gibson042
Copy link
Member

Same, but I'll give it a shot and 🤞

@gibson042 gibson042 merged commit 0c56670 into jquery:master Nov 22, 2017
@kswedberg
Copy link
Member

thank you, @gibson042 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants