Skip to main content

Bug Tracker

Side navigation

#9269 closed bug (invalid)

Opened May 13, 2011 02:55AM UTC

Closed May 13, 2011 02:14PM UTC

$.attr bug in IE

Reported by: dh20156@126.com Owned by: timmywil
Priority: low Milestone: 1.next
Component: attributes Version: 1.6.1
Keywords: Cc:
Blocked by: Blocking:
Description

Guys, we found there is a bug of $.attr in IE.

you can duplicate it as below test case:

http://jsfiddle.net/KdpTr/

or you can test it directly from:

http://www.jslab.org.cn/?tag=JQueryAttrBugInIE

When we set a boolean value(true) via $.attr, and then we compare(===) the value that get from $.attr again with true, it will be failured.

Attachments (0)
Change History (2)

Changed May 13, 2011 03:58AM UTC by rwaldron comment:1

component: unfiledattributes
owner: → timmywil
status: newassigned

Changed May 13, 2011 02:14PM UTC by timmywil comment:2

priority: undecidedlow
resolution: → invalid
status: assignedclosed

It has never been the case that you could compare the return values with strict equal to true or false. You can do

if ( $('#foo').attr('selected') ) { /* Do something */ }

getAttribute will not consistently return a boolean either because you can only set attributes to strings. I look at your fiddle in Chrome and see that getAttribute returns a string (as it should). If you get back a boolean, it's a browser bug. jQuery normalizes all of them to a strings.