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

Separate no-ready rule and enforce deprecations #52

Closed
edg2s opened this issue Jan 21, 2019 · 1 comment
Closed

Separate no-ready rule and enforce deprecations #52

edg2s opened this issue Jan 21, 2019 · 1 comment

Comments

@edg2s
Copy link
Member

edg2s commented Jan 21, 2019

From https://api.jquery.com/ready/:

jQuery offers several ways to attach a function that will run when the DOM is ready. All of the following syntaxes are equivalent:

  • $( handler )
  • $( document ).ready( handler )
  • $( "document" ).ready( handler )
  • $( "img" ).ready( handler )
  • $().ready( handler )

As of jQuery 3.0, only the first syntax is recommended; the other syntaxes still work but are deprecated. This is because the selection has no bearing on the behavior of the .ready() method, which is inefficient and can lead to incorrect assumptions about the method's behavior. For example, the third syntax works with "document" which selects nothing. The fourth syntax waits for the document to be ready but implies (incorrectly) that it waits for images to become ready.

There is also $(document).on( "ready", handler ), deprecated as of jQuery 1.8 and removed in jQuery 3.0. Note that if the DOM becomes ready before this event is attached, the handler will not be executed.

@edg2s
Copy link
Member Author

edg2s commented Jan 21, 2019

This means we should create a no-ready-shorthand rule that blocks $().ready, but not $(fn), and add that to deprecated-3.0. Also a no-on-ready (no-ready-event?) rule that blocks $(..).on('ready', ...) and add that to deprecated-1.8.

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

1 participant