jquery / jquery/api.jquery.com

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

Open
#1,035 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
HTML
Stars
325
Forks
260
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the jQuery.data documentation page and compare its parameter signatures with src/data/var/acceptData.js, which the issue identifies as evidence for supported nodes. Update the documentation so the first parameter accurately reflects the accepted Document type and clarify the mentioned object behavior if confirmed. Done means the published signatures match the supported inputs.

Written by the indexing model from the issue text.

Assessment

Tech stack
jquery
Domain
documentation
Issue type
Documentation
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.