Bug Tracker

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#12411 closed feature (fixed)

.removeClass(undefined) works not as expected

Reported by: matthias.jaeggli@… Owned by: matthias.jaeggli@…
Priority: low Milestone: None
Component: attributes Version: 1.8.0
Keywords: Cc:
Blocked by: Blocking:

Description

An empty function call is not the same, as calling a function with an undefined variable. If we check against !arguments.length instead of undefined, we can tell apart these situations.

OLD:
.removeClass() - removes all classes, as expected
.removeClass(undefined) - also removes all classes, which is wrong in my eyes

Fix:
.removeClass(undefined) - removes nothing, like null, false and "" do
Pull Request https://github.com/jquery/jquery/pull/913

PS:
I noticed this while calling element.removeClass(someObject.someVar); where the object was defined, but someVar was undefined, so this is a pretty common situation, I think.

Change History (5)

comment:1 Changed 7 years ago by timmywil

Component: unfiledattributes
Owner: set to matthias.jaeggli@…
Priority: undecidedlow
Status: newpending
Type: bugenhancement

Please add a test supporting this change in the PR.

comment:3 Changed 7 years ago by mikesherov

Type: enhancementfeature

comment:4 Changed 7 years ago by trac-o-bot

Resolution: invalid
Status: pendingclosed

Because we get so many tickets, we often need to return them to the initial reporter for more information. If that person does not reply within 14 days, the ticket will automatically be closed, and that has happened in this case. If you still are interested in pursuing this issue, feel free to add a comment with the requested information and we will be happy to reopen the ticket if it is still valid. Thanks!

comment:5 Changed 7 years ago by Matthias Jäggli

Resolution: invalidfixed

Fix #12411, .removeClass(undefined) is a chaining no-op. Close gh-913.

.removeClass() removes all classes, as documented .removeClass(window.nonExistentVariable) removes nothing

Changeset: 227c49a4596423a125bdcb1d25a2263e526360db

Note: See TracTickets for help on using tickets.