You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
In practice, I've used jQuery.data on Document objects for years, without any trouble.
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.
The text was updated successfully, but these errors were encountered:
leonard-thieu
added a commit
to leonard-thieu/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.
The documentation for jQuery.data gives the following signatures:
In all three the
element
parameter is typed asElement
. However, jQuery does accept anelement
which is of typeDocument
. Two pieces of evidence:In practice, I've used
jQuery.data
onDocument
objects for years, without any trouble.The data machinery calls on
acceptData
to detect whether a node is fit to be used as the first argument of thedata
function.acceptData
's code and comments both explicitly consider thatDocument
is a valid node.It seems that JavaScript objects that do not have a numeric
nodeType
field can also be used withjQuery.data
. I'm mentioning this for completeness. I've never used this capability.The text was updated successfully, but these errors were encountered: