Modify ↓
Ticket #11923 (closed bug: fixed)
.removeClass() should remove all occurrences of class name
| Reported by: | davidchambers | Owned by: | rwaldron |
|---|---|---|---|
| Priority: | low | Milestone: | None |
| Component: | attributes | Version: | 1.7.2 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
This behaviour is erroneous in my view:
> $('<b class="x x">').removeClass('x').hasClass('x')
true
Change History
comment:1 Changed 11 months ago by dmethvin
- Priority changed from undecided to low
- Status changed from new to open
- Component changed from unfiled to attributes
comment:2 Changed 11 months ago by rwaldron
- Owner set to rwaldron
- Status changed from open to assigned
comment:3 Changed 11 months ago by davidchambers
@dmethvin: Sure, I'm just keen to avoid *ever* having to write:
while ($el.hasClass('x')) $el.removeClass('x')
comment:4 Changed 11 months ago by Rick Waldron
- Status changed from assigned to closed
- Resolution set to fixed
Make removeClass smart enough to remove duplicates. Fixes #11923
Changeset: 3206be877250f5fe958a0519ef19d52e277687ca
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.
Note: See
TracTickets for help on using
tickets.

http://jsfiddle.net/yCGZj/
Yeah we should either document this or change the behavior. Note that .addClass() won't create duplicates, so the only way to get into this situation is with a class string that has dups in the first place.