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

Update the documentation of jQuery.data to indicate what the function actually accepts for the 1st parameter. #1035

Open
lddubeau opened this issue Apr 12, 2017 · 0 comments

Comments

@lddubeau
Copy link

The documentation for jQuery.data gives the following signatures:

jQuery.data( element, key, value )
jQuery.data( element, key )
jQuery.data( element )

In all three the element parameter is typed as Element. However, jQuery does accept an element which is of type Document. Two pieces of evidence:

  1. In practice, I've used jQuery.data on Document objects for years, without any trouble.

  2. The data machinery calls on acceptData to detect whether a node is fit to be used as the first argument of the data function. acceptData's code and comments both explicitly consider that Document is a valid node.

It seems that JavaScript objects that do not have a numeric nodeType field can also be used with jQuery.data. I'm mentioning this for completeness. I've never used this capability.

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
1 participant