Bug Tracker

Modify

Ticket #11923 (closed bug: fixed)

Opened 11 months ago

Last modified 11 months ago

.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

 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.

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.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.