Bug Tracker

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:


This behaviour is erroneous in my view:

> $('<b class="x x">').removeClass('x').hasClass('x')

Change History (4)

comment:1 Changed 11 years ago by dmethvin

Component: unfiledattributes
Priority: undecidedlow
Status: newopen


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.

comment:2 Changed 11 years ago by Rick Waldron

Owner: set to Rick Waldron
Status: openassigned

comment:3 Changed 11 years 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 years ago by Rick Waldron

Resolution: fixed
Status: assignedclosed

Make removeClass smart enough to remove duplicates. Fixes #11923

Changeset: 3206be877250f5fe958a0519ef19d52e277687ca

Note: See TracTickets for help on using tickets.