question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Drop `toggleClass(boolean)` and `toggleClass(undefined)` signatures

See original GitHub issue

Can 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 towards data.
  • 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:closed
  • Created 7 years ago
  • Reactions:3
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
mgolcommented, Jul 29, 2020

PR: #4766

0reactions
mgolcommented, Nov 7, 2016

Thanks for the report!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found