#12411 closed feature (fixed)
.removeClass(undefined) works not as expected
Reported by: | Owned by: | ||
---|---|---|---|
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 11 years ago by
Component: | unfiled → attributes |
---|---|
Owner: | set to [email protected]… |
Priority: | undecided → low |
Status: | new → pending |
Type: | bug → enhancement |
comment:3 Changed 11 years ago by
Type: | enhancement → feature |
---|
comment:4 Changed 11 years ago by
Resolution: | → invalid |
---|---|
Status: | pending → closed |
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 10 years ago by
Resolution: | invalid → fixed |
---|
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
Please add a test supporting this change in the PR.