Drop `toggleClass(boolean)` and `toggleClass(undefined)` signatures
See original GitHub issueCan we evaluate if these signatures can be dropped? Here’s a few arguments:
- It can mask bugs when the first argument inadvertently evaluates to
undefined
, which results in all classes being removed the first time it is called. - It’s badly documented (https://github.com/jquery/jquery/issues/1696) and because of that, probably not well-known.
- The way it saves a
__className__
data seems like a bad practice. - For custom builds, it creates a otherwise unnecessary dependency for
attributes/classes
towardsdata
. - It would allow the following savings for full builds:
raw gz Compared to master @ 5b4cb0d33731a58384e02ad51e703e7dcb00e424
-701 -230 dist/jquery.js
-168 -61 dist/jquery.min.js
Issue Analytics
- State:
- Created 7 years ago
- Reactions:3
- Comments:7 (7 by maintainers)
Top Results From Across the Web
.toggleClass() | jQuery API Documentation
toggleClass ( function [, state ] ) A function returning one or more space-separated class names or an array of class names to...
Read more >Please explain 'switch' in the .toggleClass() API?
Here is the API for the .toggleClass() method of the Jquery library. I am unsure about how to implement the switch portion. Is...
Read more >Docs | Plugins | ScrollTrigger | static.create() - GreenSock
To have toggle class names in a different way, use the callback functions (onEnter, onLeave, onLeaveBack, and onEnterBack). trigger, String | Element -...
Read more >toggleclass javascript Code Example - Code Grepper
document.getElementById('myButton').onclick = function() { this.classList.toggle('active'); }
Read more >The Complete Beginner's Guide to jQuery - Coders Campus
It has the same method signatures, which means you can use .val() ... toggleClass(className) will add or remove the given class depending on...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
PR: #4766
Thanks for the report!