Opened 12 years ago
Closed 12 years ago
#9751 closed bug (invalid)
.attr('class') returns undefined instead of blank
Reported by: | tryandls | Owned by: | |
---|---|---|---|
Priority: | low | Milestone: | 1.next |
Component: | attributes | Version: | 1.6.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
In previous versions, calling .attr('class') on an element with no class attribute (not one with class="") returned blank. It now returns undefined.
This has the potential to break code, for example something like $('#foo').attr('class').indexOf('bar').
Other than issue #9468, I can't find any mention of this issue. Tested only in FF4.
Change History (2)
comment:1 Changed 12 years ago by
comment:2 Changed 12 years ago by
Component: | unfiled → attributes |
---|---|
Priority: | undecided → low |
Resolution: | → invalid |
Status: | new → closed |
This is due to a fix in attr in 1.6 as that is the intended behavior. It should return the attribute value or undefined if the attribute is not present on the element.
Note: See
TracTickets for help on using
tickets.
Test Case http://jsfiddle.net/tryandls/HmUh6/1/
Same results in IE8