Skip to main content

Bug Tracker

Side navigation

#9751 closed bug (invalid)

Opened July 05, 2011 10:40PM UTC

Closed July 05, 2011 11:02PM UTC

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

Attachments (0)
Change History (2)

Changed July 05, 2011 10:55PM UTC by tryandls comment:1

Test Case http://jsfiddle.net/tryandls/HmUh6/1/

Same results in IE8

Changed July 05, 2011 11:02PM UTC by timmywil comment:2

component: unfiledattributes
priority: undecidedlow
resolution: → invalid
status: newclosed

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.