switchClass() removes class if removeClass and addClass params are the same
Open
Nobody has claimed this yet.
Needs info
- Dominant language
- JavaScript
- Stars
- 11.3k
- Forks
- 5.2k
- PR merge metrics
- No merged PRs in 30d
Description
I am using jQuery 3.6.0. Seems to be an undocumented "feature" with switchClass(). If I specify the same class to remove and then add, I get no class. In the following example, I would expect to see class="big":
<input type="text" id="myInput" class="big"></input>
<script>
$(document).ready(function () {
$("#myInput").switchClass("big", "big");
});
</script>
The above generates:
<input type="text" id="myInput" class="">
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the supplied switchClass("big", "big") example in jQuery UI and trace the switchClass implementation. Done means identical removeClass and addClass parameters no longer leave the element without its class, with a regression test covering the reported behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, jquery
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100