codingjoe / django-select2

This is a Django integration for Select2
https://django-select2.rtfd.io
MIT License
172 stars 53 forks source link

jQuery.isArray is deprecated; use Array.isArray 🐛 #267

Closed jamesleesaunders closed 9 months ago

jamesleesaunders commented 9 months ago

Bug Description

While testing django-select2 with the latest version of jQuery there is a deprecation notice:

This is fixed in the latest version os select2 (4.1.0) but django-select2 is shipping with (4.0.13).

jQuery.isArray is being removed in jQuery 4.0.

Im Using: django-select2: 8.1.2

Also see: https://github.com/select2/select2/issues/6298

jquery.js:1 JQMIGRATE: Migrate is installed with logging active, version 3.4.1
jquery.js:1 jQuery Version 3.7.1 Loaded
jquery.js:1 JQMIGRATE: jQuery.isArray is deprecated; use Array.isArray <-- HERE.
a @ jquery.js:1
t.<computed> @ jquery.js:1
n._resolveLanguage @ select2.full.min.js:2
n.applyFromElement @ select2.full.min.js:2
e @ select2.full.min.js:2
d @ select2.full.min.js:2
(anonymous) @ select2.full.min.js:2
each @ jquery.js:1
each @ jquery.js:1
r.fn.select2 @ select2.full.min.js:2
initHeavy @ django_select2.js:48
(anonymous) @ django_select2.js:56
each @ jquery.js:1
        if (self.options.get('debug') && window.console && console.error) {
          // Check to make sure that the response included a `results` key.
          if (!results || !results.results || !$.isArray(results.results)) {             <--- HERE
            console.error(
              'Select2: The AJAX results did not return an array in the ' +
              '`results` key of the response.'
            );
          }
        }

Steps to Reproduce

Install jquery-migrate plugin. Open browser console. View warning:jQuery.isArray is being removed in jQuery 4.0.

Expected Behavior

I expect django-select2 to be prepared for the use of jQuery 4.0.0

codingjoe commented 9 months ago

Hi @jamesleesaunders,

Thank you for reaching out. However, I am afraid, the issue you are describing is in Select2. There is already an open issue regarding your question as well, right here: https://github.com/select2/select2/issues/6298

I am taking the liberty to close this issue. Since we don't bundle Select2 but point to the latest release, the issue will resolve itself.

Cheers! Joe

jamesleesaunders commented 9 months ago

Thanks @codingjoe understood. The current version of django-select2 v8.1.2 is shipping with select2.js v4.0.13. (where the latest is v4.1.0).

Understood you bundle the latest at point of release. select2.js has already made a number of changes in preparation for jQuery4 removing deprecated jQuery functions, once https://github.com/select2/select2/issues/6298 is concluded and fully tested will you (django-select2) also be releasing a new version so that it also supports jQuery4?

Thanks for providing django-select2 !!

codingjoe commented 9 months ago

We use Django's vendored version by default, but you can provide your own version, via the SELECT2_JS setting.

However, if you open a ticket on the Django project itself. I am happy to help you get it pushed into the next bugfix release of Django. Just post the link to the issue on code.djangoproject.com here, an I am happy to help.