Hi Guys,

Great job on Prototype 1.5.1rc3 8) !
When I updated I noticed a lot of my onmouseover events were acting
funny.

my handlers looked like Tooltip.show(event, forceShow)....

I expected the Event object as the first param and then the second to
be a flag that would bypass the delay and show the tooltip instantly.

Well. It turns out now that the event object is the first and second
param because:

Function.prototype.bindAsEventListener = function(object) {
  var __method = this, args = $A(arguments), object = args.shift();
  return function(event) {
    return __method.apply(object, [( event ||
window.event)].concat(args).concat($A(arguments)));
  };
};

is appending it to the front of the args array, when it already
exists.

The docs mention something about fixing an MSIE issue but I am using
MSIE and the event object is being passed in as the first. This
creates a case of the first two params being Event objects.

A check if the event object is the first param before adding it is
needed.

Or maybe a method similar to:
http://ajaxian.com/archives/openlaszlo-how-we-deal-with-browser-quirks

Here is my attempt to fix it, this works for IE and Firefox, not sure
about the rest.

Function.prototype.bindAsEventListener = function(object) {
  var __method = this, bindArgs = $A(arguments), object =
bindArgs.shift();

  return function(event) {

    var methodArgs, funcArgs = $A(arguments);
    var hasEvent = (typeof funcArgs[0] == 'object' && (/[a-zA-Z]Event
\]/.test(funcArgs[0]) || typeof funcArgs[0].srcElement !=
'undefined'));

    if(hasEvent){
      methodArgs = bindArgs.concat(funcArgs);
    }else{
      methodArgs = [( event ||
window.event)].concat(bindArgs).concat(funcArgs);
    }

    return __method.apply(object, methodArgs);
  };
};


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to