#14311 closed bug (duplicate)
removeClass fails when passed undefined
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | unfiled | Version: | 1.10.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
See line 58 of classes.js
This matters a LOT when used with jQuery UI as it will pass undefined to the core function *always*.
Slightly shocked that there isn't a test case for this...
Change History (6)
comment:1 Changed 10 years ago by
comment:2 Changed 10 years ago by
Resolution: | → duplicate |
---|---|
Status: | new → closed |
Duplicate of #13367.
Why would there be a test case for a usage that isn't documented as doing anything?
comment:3 Changed 10 years ago by
Not only is this behavior intentional, but it is tested: https://github.com/jquery/jquery/blob/a7a3b8ce1b602f4e87539e934005875e648be192/test/unit/attributes.js#L1187-L1194
comment:4 Changed 10 years ago by
To be clear then: it is undocumented behavior that *used to* work, and has caused a bug in jQuery UI. It may be intentional now, fine, but it is undocumented. So that needs to be fixed - it should be in the documentation and added to migration guidelines.
The reason I know this used to work is that I just upgrade a very large website (with 10's of millions of users) to use the 1.10.x branch. They were a couple of years out of date - but this worked fine.
This undocumented but previously reliable behavior change broke a good few things. Like it did on a very recent version of jQuery that is still available for download (1.9.x).
So even if it is *intended* I'd question the reasoning behind that intention.
comment:5 Changed 10 years ago by
This is a heartwarming story of triumph and tragedy, but it lacks a jsfiddle.net case.
comment:6 Changed 10 years ago by
it is undocumented behavior that *used to* work, and has caused a bug in jQuery UI.
Anything that is undocumented is invalid, regardless of whether it happens to work at a given point in time. Yes, the change revealed a bug in jQuery UI. That bug was fixed seven months ago.
Note - test with jQuery UI 1.9 to see elem.removeClass() function fail silently.
Passing undefined isn't even required with that. It just outright fails (due to how 1.9 is written, UI 1.10 actually works around this bug with a much more complicated solution but the bug is actually in jquery core).