Skip to main content

Bug Tracker

Side navigation

#11923 closed bug (fixed)

Opened June 18, 2012 01:35AM UTC

Closed June 23, 2012 11:38PM UTC

.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:
Blocked by: Blocking:
Description

This behaviour is erroneous in my view:

> $('<b class="x x">').removeClass('x').hasClass('x')
true
Attachments (0)
Change History (4)

Changed June 23, 2012 01:49PM UTC by dmethvin comment:1

component: unfiledattributes
priority: undecidedlow
status: newopen

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.

Changed June 23, 2012 03:45PM UTC by rwaldron comment:2

owner: → rwaldron
status: openassigned

Changed June 23, 2012 06:06PM UTC by davidchambers comment:3

@dmethvin: Sure, I'm just keen to avoid *ever* having to write:

while ($el.hasClass('x')) $el.removeClass('x')

Changed June 23, 2012 11:38PM UTC by Rick Waldron comment:4

resolution: → fixed
status: assignedclosed

Make removeClass smart enough to remove duplicates. Fixes #11923

Changeset: 3206be877250f5fe958a0519ef19d52e277687ca