Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert jQuery statements that manipulate CSS to their native equivalents #920

Closed
Jaifroid opened this issue Nov 14, 2022 · 7 comments · Fixed by #927
Closed

Convert jQuery statements that manipulate CSS to their native equivalents #920

Jaifroid opened this issue Nov 14, 2022 · 7 comments · Fixed by #927
Assignees
Labels
cleanup remove-jquery Issues or PRs involving removal of jQuery
Milestone

Comments

@Jaifroid
Copy link
Member

Sub-issue of #367. This will involve converting jQeury $('.selector') statements to querySelector or querySelectorAll, iterating over all selected nodes where necessary. Also deal with adding, removing or toggling CSS.

@Jaifroid Jaifroid added cleanup remove-jquery Issues or PRs involving removal of jQuery labels Nov 14, 2022
@Jaifroid Jaifroid added this to the v3.7 milestone Nov 14, 2022
@dheerajdlalwani
Copy link
Contributor

Another not so difficult issue. Mind if I take this one up? @Jaifroid

@Jaifroid
Copy link
Member Author

Yes of course, please do.

@Jaifroid
Copy link
Member Author

Jaifroid commented Nov 21, 2022

Note that some of these will involve iterating over the collection of nodes selected by querySelectorAll() (which is what you'll want to use instead of jQuery class selectors). You have to be careful iterating collections of nodes in a way that is compatible with IE11. In many cases you will have to use something like:

       Array.prototype.slice.call(document.querySelectorAll('.selector')).forEach(function (node) {
            ...
        });

@dheerajdlalwani
Copy link
Contributor

Yes of course, please do.

Awesome. I'll get started.

@dheerajdlalwani
Copy link
Contributor

Note that some of these will involve iterating over the collection of nodes selected by querySelectorAll() (which is what you'll want to use instead of jQuery class selectors). You have to be careful iterating collections of nodes in a way that is compatible with IE11. In many cases you will have to use something like:

       Array.prototype.slice.call(document.querySelectorAll('.selector')).forEach(function (node) {
            ...
        });

Alright! Thank you for informing. I'll be careful.

Also if you don't mind me asking, why are we still supporting IE 11? And how long do we plan to do that? Just wanted to understand the thought process behind it.

@Jaifroid
Copy link
Member Author

why are we still supporting IE 11?

Good question. There are a number of old browsers we still try to support, either due to a conservative user base (very old Firefox) or to frameworks that still rely on old browsers or web views, and IE11 is a kind of baseline that ensures very wide compatibility. The medium-term aim is to start using modern code (probably TypeScript too) and compile down to our target browsers -- see #554. We're not there yet, due to lack of human-power to work on these things, hence we try to keep support manually for now till we can implement that issue. Where a feature cannot be done in a compatible way, we bypass that feature for old browsers in the app. An example is Service Worker support, which is now the default. What we still call "JQuery mode" (but hopefully can stop calling it that soon) is the version that is deprecated but still compatible with almost anything.

@dheerajdlalwani
Copy link
Contributor

Okay, I am opening a PR for this, but I am not sure if I've been on the right track. Just take a look, @Jaifroid .
There weren't many jQuery statements which were manipulating CSS, although I did convert a bunch of other jQuery functions to native JS. Take a look at the PR, let me know if I am doing the right thing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cleanup remove-jquery Issues or PRs involving removal of jQuery
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants