This project is archived and is in readonly mode.

#803 ✓wontfix
Mark Story

Event should include currentTarget property

Reported by Mark Story | December 13th, 2009 @ 02:47 PM | in 2.0 (closed)

The currentTarget property of the W3C Event object contains a reference to the element currently handling the event. This property is not available in IE, and not made reliably available by mootools. I think adding support for currentTarget could be useful as it allows you to bind a class instance to this in an event handler, and still have access to the element handling the event.

this.button.addEvent('click', function (event) {
   var el = $(event.currentTarget);
}, this);

With the current implementation, you would normally create a var self = this reference in the enclosing scope to gain access to the class instance. While this is perfectly functional, I think currentTarget offers some syntactic sugar over the current solution.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Shared Ticket Bins