Bug Tracker

Ticket #9298 (closed enhancement: fixed)

Opened 3 years ago

Last modified 3 years ago

$(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:
Blocking: Blocked by:

Description

 http://jsbin.com/ociju4

Check this

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

Change History

comment:1 follow-up: ↓ 4 Changed 3 years ago by timmywil

  • Status changed from new to closed
  • Resolution set to fixed

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

Changeset: a5cf257a8a240f96f1ec255599fa1d1190f51ff5

comment:2 Changed 3 years ago by timmywil

  • Priority changed from undecided to low
  • Component changed from unfiled to attributes
  • Milestone changed from 1.next to 1.6.2

comment:3 Changed 3 years ago by timmywil

#9299 is a duplicate of this ticket.

comment:4 in reply to: ↑ 1 Changed 3 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 3 years ago by rwaldron

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

comment:6 follow-up: ↓ 7 Changed 3 years ago by 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.

Last edited 3 years ago by timmywil (previous) (diff)

comment:7 in reply to: ↑ 6 Changed 3 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 follow-up: ↓ 9 Changed 3 years ago by 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

comment:9 in reply to: ↑ 8 Changed 3 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.