Side navigation
#9630 closed bug (fixed)
Opened June 21, 2011 07:18AM UTC
Closed August 04, 2011 09:33PM UTC
Last modified August 26, 2011 02:50AM UTC
foo.contents().hasClass() returns incorrect value
Reported by: | olov.lassus | Owned by: | rwaldron |
---|---|---|---|
Priority: | low | Milestone: | 1.6.3 |
Component: | attributes | Version: | 1.6.1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
hasClass("undefined") returns true incorrectly for elements that do no have the className property (as opposed to having it set to ""), such as text and comment nodes.
Verified with Chrome 12 and Firefox 5.
Pull request for patch and test case to follow.
Attachments (0)
Change History (12)
Changed June 21, 2011 07:34AM UTC by comment:1
Changed June 21, 2011 03:30PM UTC by comment:2
component: | unfiled → attributes |
---|---|
priority: | undecided → low |
resolution: | → worksforme |
status: | new → closed |
This is a non-issue.
Changed June 21, 2011 03:42PM UTC by comment:3
As I demonstrated in the test case included in the pull request this is working as expected for DIV nodes (I included that expectation for completeness) but not for text and comment nodes.
The jsFiddle test you linked to just shows that this is a non-issue for DIV nodes, doesn't it?
Changed June 21, 2011 04:01PM UTC by comment:4
Right, but the add|removeClass methods only care about nodeType 1 ( https://developer.mozilla.org/en/nodeType )
Updated:
Changed June 21, 2011 05:34PM UTC by comment:5
That's fine and I see the nodeType guards in addClass/removeClass, but what about hasClass? Should one be able to rely on jQuery("div").contents().hasClass or not? The existing hasClass implementation contains no guards and is used in that manner in your existing unit tests.
http://jsfiddle.net/olov/sMceh/ is reduced to make it clearer
Changed June 21, 2011 05:56PM UTC by comment:6
resolution: | worksforme |
---|---|
status: | closed → reopened |
summary: | hasClass("undefined") returns incorrect value for text and comment nodes → foo.contents().hasClass() returns incorrect value |
Changed June 21, 2011 06:00PM UTC by comment:7
owner: | → rwaldron |
---|---|
status: | reopened → assigned |
Changed June 21, 2011 06:06PM UTC by comment:8
Changed June 22, 2011 06:15AM UTC by comment:9
_comment0: | Do you consider the patch in my pull request adequate for fixing this issue? → 1308750358834541 |
---|
Do you consider the patch in my pull request adequate for fixing this issue?
''edit: https://github.com/jquery/jquery/pull/419 is now updated with a correct test case and the bugfix so landing that will fix this ticket''
Changed July 12, 2011 04:59PM UTC by comment:10
milestone: | 1.next → 1.7 |
---|
Changed August 04, 2011 09:33PM UTC by comment:11
Changed August 26, 2011 02:50AM UTC by comment:12
milestone: | 1.7 → 1.6.3 |
---|
Submitted pull request https://github.com/jquery/jquery/pull/418.
Reference to forum post http://forum.jquery.com/topic/i-made-jquery-restrict-mode-clean-and-i-think-i-found-a-tiny-bug-doing-so.