Bug Tracker

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#13531 closed bug (duplicate)

jQuery-1.9.1 removeClass() not working properly

Reported by: adam.levitt@… Owned by: adam.levitt@…
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;

Change History (7)

comment:1 Changed 6 years ago by dmethvin

Owner: set to adam.levitt@…
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.

comment:2 in reply to:  description Changed 6 years ago by anonymous

Replying to 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]);

comment:3 Changed 6 years ago by dmethvin

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().

comment:4 Changed 6 years ago by dguzzo@…

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.

comment:5 Changed 6 years ago by scottgonzalez

Resolution: duplicate
Status: pendingclosed

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

comment:6 in reply to:  5 Changed 6 years ago by anonymous

Replying to 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!) :)

comment:7 Changed 6 years ago by vernmic@…

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

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

Note: See TracTickets for help on using tickets.