Skip to content
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

$.getScript is missing a signature #1052

Open
oriadam opened this issue Jul 5, 2017 · 4 comments
Open

$.getScript is missing a signature #1052

oriadam opened this issue Jul 5, 2017 · 4 comments

Comments

@oriadam
Copy link

oriadam commented Jul 5, 2017

jQuery 1.12.0 added a signature for passing an options object to $.getScript.
The options are padded on to $.ajax.

  1. The signature should be added to the docs
  2. In the Examples section, if you want to enable browser caching it is recommended to add a new function. This is not a good practice, and since 1.12.0 there is no use for it. One can simply:
    $.getScript({
        url: "foo.js",
        cache: true
    })

The above example should be added to the examples section, for jQuery 1.12.0 or later.

https://api.jquery.com/jquery.getscript/

@mgol
Copy link
Member

mgol commented Jul 5, 2017

Thanks for the report. Would you like to submit a PR?

@oriadam
Copy link
Author

oriadam commented Jul 5, 2017

Created PR 1054

@mgol
Copy link
Member

mgol commented Jul 26, 2017

Looking into it now, I think this signature is still not supported. It only works by accident due to changes in jQuery.get. I'm not opposed to support that but we'd need unit tests ensuring it works merged to the jQuery repository first.

Would you open an issue there to discuss adding official support? Once it's accepted, we would accept a PR.

@oriadam
Copy link
Author

oriadam commented Jul 26, 2017

Sure, opened the issue:
jquery/jquery#3736

The code looks good, doesn't look like accident.
It makes a lot of sense too, similar to other ajax APIs that accepts the options object.

leonard-thieu added a commit to leonard-thieu/DefinitelyTyped that referenced this issue Oct 8, 2018
ghost pushed a commit to DefinitelyTyped/DefinitelyTyped that referenced this issue Oct 9, 2018
…oads for `jQuery.getScript` and Data APIs. (#29573)

* [jquery] Introduce interface for `jQuery.fx`.

* [jquery] Attach `jQuery.Deferred` documentation to correct symbol.

* [jquery] Convert `jQuery.Callbacks` to an interface.

This change is purely for consistency with similar properties (e.g. `jQuery.Deferred`, `jQuery.Event`).

* [jquery] For `JQuery`, reduce examples to only those relevant to the overload and use shorter template for code-only examples.

* [jquery] For `JQueryStatic`, reduce examples to only those relevant to the overload and use shorter template for code-only examples.

* [jquery] For `JQuery.Event`, reduce examples to only those relevant to the overload and use shorter template for code-only examples.

* [jquery] For `JQuery.Callbacks`, reduce examples to only those relevant to the overload and use shorter template for code-only examples.

* [jquery] For `JQuery.PromiseBase`/`JQuery.Deferred`, reduce examples to only those relevant to the overload and use shorter template for code-only examples.

* [jquery] Consistent ordering.

* [jquery] Add `jQuery.getScript(options)`.

See jquery/api.jquery.com#1052.

* [jquery] Fix documentation for this one overload of `jQuery.proxy`.

* [jquery] Accept `Document`, `Window`, and `JQuery.PlainObject` for the `element` parameter of Data APIs.

See https://github.com/jquery/jquery/blob/354f6036f251a3ce9b24cd7b228b4c7a79001520/test/unit/data.js#L142-L164 and jquery/api.jquery.com#1035.

* [jquery] Add `jQuery.cleanData`.

See jquery/api.jquery.com#996.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants