kenwheeler / slick

the last carousel you'll ever need
kenwheeler.github.io/slick
MIT License
28.34k stars 5.88k forks source link

jQuery.type is deprecated #4064

Open srextasagar32 opened 3 years ago

srextasagar32 commented 3 years ago

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 commented 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'

Tharkon commented 3 years ago

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 commented 1 year ago

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!

charlescurrier commented 1 year ago

There 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