[Prototype-core] Re: modified lib to support currentTarget in IE

2009-01-11 Thread Varga-Háli Dániel

I have got a few things here...
Tobie, I don't know what LH is so please tell me how I can open a
ticket. I am not that much into these kinda things. I've been using
prototype for a couple of weeks.

Diego...
this references to the current scope in my case therefore it could not
be used. Let me give you an example to what I mean. Maybe it is easier
to paste a URL here with the example:

http://pastebin.com/f6264fce4

Thanx for the replies anyways :)

Daniel

2009/1/11 Diego Perini diego.per...@gmail.com:


 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 kan...@gmail.com wrote:
 On Jan 10, 11:12 am, Varga-Háli Dániel vargada...@gmail.com 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 prototype-core@googlegroups.com
To unsubscribe from this group, send email to 
prototype-core-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~--~~~~--~~--~--~---



[Prototype-core] Re: modified lib to support currentTarget in IE

2009-01-11 Thread Diego Perini

Daniel,
you are correct you wrapped the handler so this is lost, fixing the
event properties in the initial IE wrapper is the way to go, and it is
also faster.

Anyway I am not sure you can modify Prototype by simply adding another
wrapper on top of the original handler. Maybe it works for you because
you don't need to remove the handlers once set to listen.

References to original handlers are lost in the wrapping process, thus
no way of removing them, a new instance of each wrapper should be
maintained to be able to do that. My NWEvents manager does that both
with normal events and with event delegation.

I don't know if there is some Prototype magic that I am missing and
that can help in this situation. As Tobie said, maybe a change in the
implementation is needed.


Diego


On 11 Gen, 10:44, Varga-Háli Dániel vargada...@gmail.com wrote:
 I have got a few things here...
 Tobie, I don't know what LH is so please tell me how I can open a
 ticket. I am not that much into these kinda things. I've been using
 prototype for a couple of weeks.

 Diego...
 this references to the current scope in my case therefore it could not
 be used. Let me give you an example to what I mean. Maybe it is easier
 to paste a URL here with the example:

 http://pastebin.com/f6264fce4

 Thanx for the replies anyways :)

 Daniel

 2009/1/11 Diego Perini diego.per...@gmail.com:



  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 kan...@gmail.com wrote:
  On Jan 10, 11:12 am, Varga-Háli Dániel vargada...@gmail.com 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 prototype-core@googlegroups.com
To unsubscribe from this group, send email to 
prototype-core-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~--~~~~--~~--~--~---



[Prototype-core] Re: modified lib to support currentTarget in IE

2009-01-11 Thread Tobie Langel

Daniel, you can find more information on how to contribute here:
http://prototypejs.org/contribute

Diego, the this binding is fixed for IE, however, the currentTarget
property isn't.

I think both would be useful.

Best,

Tobie

On Jan 11, 5:01 pm, Diego Perini diego.per...@gmail.com wrote:
 Daniel,
 you are correct you wrapped the handler so this is lost, fixing the
 event properties in the initial IE wrapper is the way to go, and it is
 also faster.

 Anyway I am not sure you can modify Prototype by simply adding another
 wrapper on top of the original handler. Maybe it works for you because
 you don't need to remove the handlers once set to listen.

 References to original handlers are lost in the wrapping process, thus
 no way of removing them, a new instance of each wrapper should be
 maintained to be able to do that. My NWEvents manager does that both
 with normal events and with event delegation.

 I don't know if there is some Prototype magic that I am missing and
 that can help in this situation. As Tobie said, maybe a change in the
 implementation is needed.

 Diego

 On 11 Gen, 10:44, Varga-Háli Dániel vargada...@gmail.com wrote:

  I have got a few things here...
  Tobie, I don't know what LH is so please tell me how I can open a
  ticket. I am not that much into these kinda things. I've been using
  prototype for a couple of weeks.

  Diego...
  this references to the current scope in my case therefore it could not
  be used. Let me give you an example to what I mean. Maybe it is easier
  to paste a URL here with the example:

 http://pastebin.com/f6264fce4

  Thanx for the replies anyways :)

  Daniel

  2009/1/11 Diego Perini diego.per...@gmail.com:

   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 kan...@gmail.com wrote:
   On Jan 10, 11:12 am, Varga-Háli Dániel vargada...@gmail.com 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 prototype-core@googlegroups.com
To unsubscribe from this group, send email to 
prototype-core-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~--~~~~--~~--~--~---



[Prototype-core] Re: modified lib to support currentTarget in IE

2009-01-10 Thread Tobie Langel

Hi Daniel,

Thanks for the suggestion.

It might be worthwhile to rethink the implementation.

Would you mind opening a ticket for this in LH and mark it as an
enhancement.

You can assign the ticket to me.

Best,

Tobie


On Jan 10, 5:12 pm, Varga-Háli Dániel vargada...@gmail.com 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...

 Regards: Daniel Varga
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype: Core group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to 
prototype-core-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~--~~~~--~~--~--~---



[Prototype-core] Re: modified lib to support currentTarget in IE

2009-01-10 Thread kangax

On Jan 10, 11:12 am, Varga-Háli Dániel vargada...@gmail.com 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 prototype-core@googlegroups.com
To unsubscribe from this group, send email to 
prototype-core-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~--~~~~--~~--~--~---



[Prototype-core] Re: modified lib to support currentTarget in IE

2009-01-10 Thread Diego Perini


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 kan...@gmail.com wrote:
 On Jan 10, 11:12 am, Varga-Háli Dániel vargada...@gmail.com 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 prototype-core@googlegroups.com
To unsubscribe from this group, send email to 
prototype-core-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~--~~~~--~~--~--~---