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

Resolve jQuery.fn.focus() event shorthand deprecation #259

Open
jrun opened this issue Oct 5, 2018 · 0 comments
Open

Resolve jQuery.fn.focus() event shorthand deprecation #259

jrun opened this issue Oct 5, 2018 · 0 comments

Comments

@jrun
Copy link

jrun commented Oct 5, 2018

While updating an app to jQuery 3.3.x, I noticed a jQuery deprecation warning indicating the event shorthand methods have been deprecated. It seems there are no plans to ever remove them but they've been removed from the slim version of the package.

Even though there are no plans to actually remove the methods, does it makes sense to clear up the deprecation?

JQMIGRATE: jQuery.fn.click() event shorthand is deprecated

Cause: The .on() and .trigger() methods can set an event handler or generate an event for any event > type, and should be used instead of the shortcut methods. This message also applies to the other > event shorthands, including: blur, focus, focusin, focusout, resize, scroll, dblclick, mousedown, mouseup, mousemove, mouseover, mouseout, mouseenter, mouseleave, change, select, submit, keydown, keypress, keyup, and contextmenu.

Solution: Instead of .click(fn) use .on("click", fn). Instead of .click() use .trigger("click").

Source

modified   src/intercooler.js
@@ -733,7 +733,7 @@ var Intercooler = Intercooler || (function() {
   }
 
   function autoFocus(elt) {
-    elt.find('[autofocus]').last().focus();
+    elt.find('[autofocus]').last().trigger('focus');
   }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant