Opened 14 years ago

Closed 14 years ago

Last modified 12 years ago

#527 closed enhancement (fixed)

Requesting dojo.event.connect set up currentTarget in IE

Reported by: cris@… Owned by: sjmiles
Priority: high Milestone:
Component: Core Version: 0.2
Keywords: event, connect, currentTarget Cc: jeoffwilks@…
Blocked By: Blocking:

Description

Dojo "fixes" various event properties, giving standard properties their standard values in IE. Apparently currentTarget is not currently set up, and it would be very nice if it were.

Change History (7)

comment:1 Changed 14 years ago by anonymous

I guess I should thank cris@… for creating a ticket for me. For a detailed explanation of the problem, please look at my original message on dojo-interest.

The crux of the matter is that while IE events don't supply the currentTarget property, you can work around that by referencing this, which is effectively the same as the currentTarget would be:

a_nodes[i].onclick = function (event) {
    ...
    href = this.href;    //works great in IE and Mozilla
    ...
}

But dojo doesn't capture it in this or in currentTarget.

dojo.event.connect(a_nodes[i], "onclick", function (event) {
    ...
    href = event.currentTarget.href;  //works great in Moz but not in IE
    ...
}
dojo.event.connect(a_nodes[i], "onclick", function (event) {
    ...
    href = this.href;  //doesn't work at all
    ...
}

The problem would be solved if dojo would, for IE, save the original this into the fixed-up event as currentTarget.

References

The best explanation comes from http://www.quirksmode.org/js/events_order.html

"But how do you know which HTML element is currently handling the event? target/srcElement don’t give a clue, they always refer to element2 since it is the original source of the event.

"To solve this problem W3C has added the currentTarget property. It contains a reference to the HTML element the event is currently being handled by: exactly what we need. Unfortunately the Microsoft model doesn’t contain a similar property.

"You can also use the this keyword. In the example above it refers to the HTML element the event is handled on, just like currentTarget."

comment:2 Changed 14 years ago by anonymous

Milestone: 0.3release
Owner: changed from anonymous to sjmiles

comment:3 Changed 14 years ago by sjmiles

Resolution: fixed
Status: newclosed

comment:4 Changed 14 years ago by anonymous

evt.currentTarget should now be correct on IE.

comment:5 Changed 14 years ago by sjmiles

Keywords: event connect currentTarget added

comment:6 Changed 14 years ago by anonymous

(In [3309] sjmiles) "Added (optional) second parameter (sender) to event.browser.fixEvent to fix missing currentTarget property on IE. Modified five instances of fixEvent invocations to pass 'this' for 'sender'."

Thanks!

comment:7 Changed 12 years ago by (none)

Milestone: 0.3release

Milestone 0.3release deleted

Note: See TracTickets for help on using tickets.