Comments (13)
I'm sure I don't speak for everyone, and I'm not sure how much effort the jQuery 4 migration will require, but personally as a user, if substantial effort is going to be spent on a migration I'd much rather it be spent on removing the jQuery dependency altogether (#6196).
from select2.
https://github.com/marcellov7/select2/tree/support-jQuery-4.0.0-beta
I should have sorted everything out, it seems OK in the testing part too.
Please review and pull request if necessary.
Thanks
from select2.
I would love it if this project would refactor to eliminate deprecated calls.
from select2.
One first observation testing select2 with jQuery4 is:
- jQuery.isArray is deprecated; use Array.isArray
jQuery: 3.7.1
select2: 4.1.0-rc.0
django-select2: 8.1.2
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.'
);
}
}
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
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
$.fn.djangoSelect2 @ django_select2.js:53
(anonymous) @ django_select2.js:71
l @ jquery.js:1
c @ jquery.js:1
setTimeout (async)
(anonymous) @ jquery.js:1
u @ jquery.js:1
fireWith @ jquery.js:1
fire @ jquery.js:1
u @ jquery.js:1
fireWith @ jquery.js:1
ready @ jquery.js:1
Z @ jquery.js:1
jquery.js:1 console.trace
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
$.fn.djangoSelect2 @ django_select2.js:53
(anonymous) @ django_select2.js:71
l @ jquery.js:1
c @ jquery.js:1
setTimeout (async)
(anonymous) @ jquery.js:1
u @ jquery.js:1
fireWith @ jquery.js:1
fire @ jquery.js:1
u @ jquery.js:1
fireWith @ jquery.js:1
ready @ jquery.js:1
Z @ jquery.js:1
from select2.
Also see #6253
from select2.
Would the effort be best simply refactoring the bits of code (if any) which uses these?
Otherwise if you were to be running the jQuery migrate add-on it would it still be complaining that these functions are deprecated? https://github.com/jquery/jquery-migrate
That said, granted it would still work.
from select2.
Actually, stand down on the isArray
comment above. This looks to be an issue with django-select2 including an older version of select2 (4.0.13). It looks like you have already replaced all instances of $isArray in the latest (4.1.0-rc.0).
I have raised issue over on the django-select2 side: codingjoe/django-select2#267
from select2.
In general, it seems to work, but a more in-depth analysis would be needed.
from select2.
I'm sure I don't speak for everyone, and I'm not sure how much effort the jQuery 4 migration will require, but personally as a user, if substantial effort is going to be spent on a migration I'd much rather it be spent on removing the jQuery dependency altogether (#6196).
I don't think it's strictly necessary given the nature of the plugin, there are several alternatives out there that work very well without jQuery. Also because the time it would take you to rewrite things without jQuery (if ever a Select2 without jQuery will ever be released) you have already made the switch to another one without jQuery.
Furthermore, with ChatGPT you would quickly switch to an alternative. 🤣
jQuery 4 brings notable improvements and since Select2 is incorporated into this, it is in my opinion important to do a check to determine if any problems with jQuery v4 come out, but it seems to work very well for the moment.
I opened the issue only to encourage those who are more familiar than me to carry out a more in-depth check based on the deprecate elements in jQuery 4.
from select2.
@marcellov7 : According to jQuery, camelCase no longer exists: https://blog.jquery.com/2024/02/06/jquery-4-0-0-beta/
It is used here:
select2/src/js/select2/defaults.js
Line 424 in ed1761a
Not sure what else might be broken but this one at least stood out to me as broken on one of my sites.
from select2.
Seems like it would be possible to inject the missing functions back into jQuery and use the native functions and add the extra bit that jQuery added such as null handling.
Anyone see any problems with the following code to add the missing functions back in: (after jQuery but before select2)
jQuery.isArray = Array.isArray || function (value) {
return Object.prototype.toString.call(value) === '[object Array]';
};
jQuery.trim = function (text) {
return text == null ? "" : text.trim();
};
I didn't need to replace camelCase() for some reason, but that might need to be filled in too.
from select2.
see #6196
from select2.
Hi, as the select2 maintainer of the Drupal integration, I would like to see this getting landed. The upcoming Drupal 11 release will drop jQuery 3 and use jQuery 4 instead.
So to provide a smooth migration for all Drupal users, that are using the select2 module(over 20k installations), from D10 to D11, getting this done is mandatory.
@kevin-brown Could you please provide a timeframe for this? I am also happy to help if necessary.
from select2.
Related Issues (20)
- Becoming a contributor to transfer issues
- Is this Repo dead? HOT 1
- Scrolling with keys, while the mouse pointer hovers over the list
- doesn't play well with standard es modules HOT 1
- select2.min.js:2 Select2: The language file for "./i18n/ko" could not be automatically loaded. A fallback will be used instead.
- REQUEST: Select2 identity based on node element or full node address, not on id attribute only. HOT 1
- website not working HOT 12
- Question on commit 181170f, delete button/tabindex HOT 2
- Select2's input has a searchbox role when it should have a combobox role. HOT 1
- There a wide space in dropdown list
- de.js on cdn
- Even with the dropdownParent setting, does not correctly position itself in modal HOT 1
- 3.5.4 version not on npm (while 3.4.3, 3.4.5, 3.5.1, etc are there) HOT 2
- A UI bug on iOS devices: iOS native window is shown after focusing on a multiple choices select element
- Select2 don't resize properly
- Selection issue on chrome browser
- NPM missing older versions HOT 1
- html placeholders? HOT 2
- Problem with numbers HOT 1
- Can not add data is substring of existing tag select2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from select2.