Bttstrp / bootstrap-switch

Turn checkboxes and radio buttons in toggle switches.
MIT License
5.08k stars 1.45k forks source link

Use Array.isArray instead of jQuery.isArray #724

Closed ncardeli closed 4 years ago

ncardeli commented 4 years ago

This is an issue I found when migrating a code base from jQuery 1.12 to jQuery 3.5.

Using jQuery-Migrate I'm getting a warning because Bootstrap Switch uses jQuery.isArray, that is deprecated.

From jQuery-Migrate:

Cause: Older versions of JavaScript made it difficult to determine if a particular object was a true Array, so jQuery provided a cross-browser function to do the work. The browsers supported by jQuery 3.0 all provide a standard method for this purpose.

Solution: Replace any calls to jQuery.isArray with Array.isArray.

Instead of using jQuery.isArray, Array.isArray should be used. This shouldn't be a problem as all the browsers supported by Bootstrap Switch implement Array.isArray.

Steps to reproduce:

On a page that uses Bootstrap Switch

  1. Include jQuery 3.5
  2. Include jQuery-Migrate 3.2 for development
  3. The following message should appear in the console when opening the page: JQMIGRATE: jQuery.isArray is deprecated; use Array.isArray