Opened 11 years ago
Closed 11 years ago
#11923 closed bug (fixed)
.removeClass() should remove all occurrences of class name
Reported by: | davidchambers | Owned by: | Rick Waldron |
---|---|---|---|
Priority: | low | Milestone: | None |
Component: | attributes | Version: | 1.7.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
This behaviour is erroneous in my view:
> $('<b class="x x">').removeClass('x').hasClass('x') true
Change History (4)
comment:1 Changed 11 years ago by
Component: | unfiled → attributes |
---|---|
Priority: | undecided → low |
Status: | new → open |
comment:2 Changed 11 years ago by
Owner: | set to Rick Waldron |
---|---|
Status: | open → assigned |
comment:3 Changed 11 years ago by
@dmethvin: Sure, I'm just keen to avoid *ever* having to write:
while ($el.hasClass('x')) $el.removeClass('x')
comment:4 Changed 11 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Make removeClass smart enough to remove duplicates. Fixes #11923
Changeset: 3206be877250f5fe958a0519ef19d52e277687ca
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.