Skip to main content

Bug Tracker

Side navigation

#13531 closed bug (duplicate)

Opened February 28, 2013 02:27AM UTC

Closed March 07, 2013 03:18PM UTC

Last modified June 18, 2013 09:19PM UTC

jQuery-1.9.1 removeClass() not working properly

Reported by: adam.levitt@12twenty.com Owned by: adam.levitt@12twenty.com
Priority: undecided Milestone: None
Component: unfiled Version: 1.9.1
Keywords: Cc:
Blocked by: Blocking:
Description

On line 2114, there is a bug for calling .removeClass() with no parameters. This check fails:

proceed = arguments.length === 0 || typeof value === "string" && value;

It fails because there is actually a single argument being passed in which is "undefined". Here was my fix:

proceed = arguments[0] === undefined || arguments.length === 0 || typeof value === "string" && value;
Attachments (0)
Change History (7)

Changed February 28, 2013 02:39AM UTC by dmethvin comment:1

owner: → adam.levitt@12twenty.com
status: newpending

Please provide a test case in jsFiddle. Sounds like something is shimming .removeClass() improperly, if there are NO arguments then arguments.length===0.

Changed February 28, 2013 05:35PM UTC by anonymous comment:2

Replying to [ticket:13531 adam.levitt@…]:

On line 2114, there is a bug for calling .removeClass() with no parameters. This check fails:
> proceed = arguments.length === 0 || typeof value === "string" && value;
> 
It fails because there is actually a single argument being passed in which is "undefined". Here was my fix:
> proceed = arguments[0] === undefined || arguments.length === 0 || typeof value === "string" && value;
> 

Here's the snippet of code in jquery.validate.password.js that's causing this issue:

var meter = $(".password-meter", element.form);
		
		meter.find(".password-meter-bar").removeClass().addClass("password-meter-bar").addClass("password-meter-" + rating.messageKey);
		meter.find(".password-meter-message")
		.removeClass()
		.addClass("password-meter-message")
		.addClass("password-meter-message-" + rating.messageKey)
		.text($.validator.passwordRating.messages[rating.messageKey]);

Changed February 28, 2013 05:44PM UTC by dmethvin comment:3

I can't run that snippet to see what .removeClass() does. Make a jsFiddle and remove all plugins, then see what .removeClass() does. If it works then some code outside jQuery is breaking .removeClass().

Changed March 07, 2013 06:52AM UTC by dguzzo@gmail.com comment:4

jQueryUI extends .removeClass() to accept

speed, easing
, and
callback
arguments. if those are provided, it calls the original jQuery definition of the function with
classNames
, which is undefined. this breaks expected behavior as Adam describes in the bug report.

http://jsfiddle.net/dguzzo/WUaWj/

(to see it work as it should, uncheck the "jQuery UI 1.9.2" checkbox and re-run. bam.

Changed March 07, 2013 03:18PM UTC by scottgonzalez comment:5

resolution: → duplicate
status: pendingclosed

Duplicate of #13367.or use jQuery UI 1.10.1. bam.

Changed March 07, 2013 06:36PM UTC by anonymous comment:6

Replying to [comment:5 scott.gonzalez]:

Duplicate of #13367.or use jQuery UI 1.10.1. bam.

yep, definitely should be fixed on the UI end (good to hear it has been—time for me to upgrade!)

:)

Changed June 18, 2013 09:19PM UTC by vernmic@hotmail.com comment:7

if you cant upgrade to 1.10.1 quite yet, this worked for me...

.removeClass().addClass(...

to

.attr("class","").addClass(...