Should use the "this" keyword, the specs says that in event handlers
the "this" keyword is a reference to the element on which the event
was registered.

So the "this" keyword is equal to the "currentTarget" event property
when the eventPhase is AT_TARGET (2), if you use observe() in
Prototype I believe that is the default.

I strongly believe that Prototype fixes the "this" keyword in IE,
somebody can confirm please ?

Diego


On 10 Gen, 18:50, kangax <[email protected]> wrote:
> On Jan 10, 11:12 am, "Varga-Háli Dániel" <[email protected]> wrote:
>
>
>
> > Hello everybody,
>
> > I have spent a few hours this day to work around the missing
> > currentTarget property of event in IE.
> > I modified therefore the core lib around line 4000 (v1.6.0)
>
> > observe: function(element, eventName, handler) {
> >       element = $(element);
> >       var name = getDOMEventName(eventName);
>
> >       var wrapper = createWrapper(element, eventName, handler);
> >       if (!wrapper) return element;
>
> >       if (element.addEventListener) {
> >         element.addEventListener(name, wrapper, false);
> >       } else {
> >           // instead of:
> >           // element.attachEvent("on" + name, wrapper);
> >           element.attachEvent("on" + name, function(e){
> >               e.currentTarget = element;
> >               wrapper(e);
> >           });
> >       }
>
> >       return element;
> >     },
>
> > I hope some of you will find is as useful as myself...
>
> Doesn't prototype's `Event.element` return `currentTarget` equivalent
> in IE?
> On the other hand, extending host objects often gets one in trouble
> (especially in IE). Why don't you try a "wrapper" approach?
>
> --
> kangax
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to