Bug Tracker

Opened 8 years ago

Closed 8 years ago

#9269 closed bug (invalid)

$.attr bug in IE

Reported by: dh20156@… 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.

Change History (2)

comment:1 Changed 8 years ago by Rick Waldron

Component: unfiledattributes
Owner: set to timmywil
Status: newassigned

comment:2 Changed 8 years ago by timmywil

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.

Note: See TracTickets for help on using tickets.