Bug Tracker

Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#9298 closed enhancement (fixed)

$(elem).attr(eventName) not working properly in IE7

Reported by: s.ronak Owned by:
Priority: low Milestone: 1.6.2
Component: attributes Version: 1.6.1
Keywords: Cc:
Blocked by: Blocking:

Description

http://jsbin.com/ociju4

Check this

IE7 returns value which is not proper as user has written.

Change History (9)

comment:1 Changed 12 years ago by Timmy Willison

Resolution: fixed
Status: newclosed

Use getAttributeNode for on attributes in IE6/7 to avoid anonymous function wrapper. Fixes #9298.

Changeset: a5cf257a8a240f96f1ec255599fa1d1190f51ff5

comment:2 Changed 12 years ago by Timmy Willison

Component: unfiledattributes
Milestone: 1.next1.6.2
Priority: undecidedlow

comment:3 Changed 12 years ago by Timmy Willison

#9299 is a duplicate of this ticket.

comment:4 in reply to:  1 Changed 12 years ago by s.ronak

Replying to timmywil:

Use getAttributeNode for on attributes in IE6/7 to avoid anonymous function wrapper. Fixes #9298.

Changeset: a5cf257a8a240f96f1ec255599fa1d1190f51ff5

I don't this this fix will work. Can I've working example?

comment:5 Changed 12 years ago by Rick Waldron

You can use this boilerplate to test the changes: http://jsfiddle.net/rwaldron/w49k8/

comment:6 Changed 12 years ago by Timmy Willison

It does. IE6 and 7 wrap anything you put in inline event handlers with an anonymous function, which is why what you get back looks different. See the type check in IE6 or 7 in the fiddle created by this ticket's duplicate: http://jsfiddle.net/timmywil/nhExE/6/. All of this is not really a big concern to the jQuery team, but the fix was easy enough and short.

Last edited 12 years ago by Timmy Willison (previous) (diff)

comment:7 in reply to:  6 Changed 12 years ago by s.ronak

Replying to timmywil:

It does. IE6 and 7 wrap anything you put in inline event handlers with an anonymous function, which is why what you get back looks different. See the type check in IE6 or 7 in the fiddle created by this ticket's duplicate: http://jsfiddle.net/timmywil/nhExE/6/. All of this is not really a big concern to the jQuery team, but the fix was easy enough and short.

Ok Timmy, you've fixed it. But what is jQuery edge?? And if I write elem.getAttributeNode('onclick') it returns object. What is the final solution implemented?

comment:8 Changed 12 years ago by Timmy Willison

jQuery edge is how jsfiddle refers to the git version of jQuery (I'm not sure why). See the list of libraries on jsfiddle. getAttributeNode does return objects (attribute nodes in fact), but you can then retrieve it's value.

elem.getAttributeNode("onclick").nodeValue

comment:9 in reply to:  8 Changed 12 years ago by s.ronak

Replying to timmywil:

jQuery edge is how jsfiddle refers to the git version of jQuery (I'm not sure why). See the list of libraries on jsfiddle. getAttributeNode does return objects (attribute nodes in fact), but you can then retrieve it's value.

elem.getAttributeNode("onclick").nodeValue

Hey, thanks Timmy. I know my bug was easy to solve, but still I'm super excited for next release as my query will be resolved in v1.6.2. Yeah...

Note: See TracTickets for help on using tickets.