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

jQuery.type is deprecated #4064

Open
srextasagar32 opened this issue Feb 5, 2021 · 4 comments
Open

jQuery.type is deprecated #4064

srextasagar32 opened this issue Feb 5, 2021 · 4 comments

Comments

@srextasagar32
Copy link

jQuery.type is deprecated on slick.min.js

Can you please upgrade slick to the latest jQuery version.. We have numerous Slick Sliders in a theme in the WordPress Repo.

WordPress is rolling out the 3.5.1 in march.

@adhamqodirov
Copy link

JQMIGRATE: jQuery.type() is deprecated
Cause: This method returns a string that indicates the type of the argument, for example "number" or "function". However, as the JavaScript language evolves this method has become problematic because new language constructs might require this function to either return a new string (potentially breaking existing code) or somehow map new constructs into existing strings (again, potentially breaking existing code). Examples of new recent JavaScript features include asynchronous functions, class constructors, Symbols, or functions that act as iterators.

Solution: Review code that uses jQuery.type() and use a type check that is appropriate for the situation. For example. if the code expects a plain function, check for typeof arg === "function".

$.type(responsiveSettings) === 'array' change to typeof responsiveSettings === 'array'

@Tharkon
Copy link

Tharkon commented Mar 11, 2021

Typeof returns 'object' for arrays because 'array' is not a possible return value.
There are six possible values that typeof returns: 'object', 'boolean', 'function', 'number', 'string', and 'undefined'.

So it will not be possible to distinguish between arrays and other objects that way. I am not sure if that's a problem.
If it is, change to Array.isArray(responsiveSettings), which does distinguish between arrays and other objects.

@TonyC5
Copy link

TonyC5 commented Sep 16, 2022

Has anyone successfully modified slick.min.js to eliminate the deprecated JQuery.type? My js knowledge isn't sufficient to perform the change for each case. For example, I don't know how to change -1!==i.type.indexOf("mouse"). Here are the .type instances that I found along with my proposed changes. If anyone can confirm my proposed changes and make corrections, that would be very helpful. Also, if anyone can suggest how to change -1!==i.type.indexOf("mouse") that would be very helpful, too. Thank you!

  • "array"===i.type(n) changed to Array.isArray(n)
  • if("object"===i.type(arguments[0]) changed to if(("object" === typeof arguments[0]) && (null !== arguments[0]))
  • "string"===i.type(arguments[0]) changed to "string"===typeof arguments[0]
  • "array"===i.type(arguments[1]) changed to Array.isArray(arguments[1])
  • "array"!==i.type(r.options.responsive) changed to !Array.isArray(r.options.responsive)
  • -1!==i.type.indexOf("mouse") I don't know how to change this

@charlescurrier
Copy link

There are some PRs to address this. The most recent one was approved 6 months ago though and has been sitting stagnant since. #4221

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

5 participants