Open srextasagar32 opened 3 years ago
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'
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.
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 thisThere are some PRs to address this. The most recent one was approved 6 months ago though and has been sitting stagnant since. https://github.com/kenwheeler/slick/pull/4221
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.