#13531 closed bug (duplicate)
jQuery-1.9.1 removeClass() not working properly
Reported by: | Owned by: | ||
---|---|---|---|
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 10 years ago by
Owner: | set to [email protected]… |
---|---|
Status: | new → pending |
comment:2 Changed 10 years ago by
Replying to [email protected]…:
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 10 years ago by
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 10 years ago by
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 follow-up: 6 Changed 10 years ago by
Resolution: | → duplicate |
---|---|
Status: | pending → closed |
Duplicate of #13367.
or use jQuery UI 1.10.1. bam.
comment:6 Changed 10 years ago by
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 10 years ago by
if you cant upgrade to 1.10.1 quite yet, this worked for me...
.removeClass().addClass(... to .attr("class","").addClass(...
Please provide a test case in jsFiddle. Sounds like something is shimming
.removeClass()
improperly, if there are NO arguments thenarguments.length===0
.